From 5ebe5d071f1c31d52cfb793c93c0903d843869fd Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 5 Apr 2021 14:35:41 -0700 Subject: [PATCH] Fixes for `wolfSSL_BIO_BASE64_write` changes. --- src/bio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bio.c b/src/bio.c index 79e792949..c2b2f2027 100644 --- a/src/bio.c +++ b/src/bio.c @@ -332,7 +332,7 @@ static int wolfSSL_BIO_BASE64_write(WOLFSSL_BIO* bio, const void* data, /* allocate buffer for encoded output */ if (*out == NULL && sz > 0) { - *out = (void*)XMALLOC(sz, front->heap, + *out = (byte*)XMALLOC(sz, front->heap, DYNAMIC_TYPE_TMP_BUFFER); if (*out == NULL) { WOLFSSL_MSG("Memory error"); @@ -340,7 +340,7 @@ static int wolfSSL_BIO_BASE64_write(WOLFSSL_BIO* bio, const void* data, } } else if (sz > *outLen) { - tmp = (void*)XREALLOC(*out, sz, front->heap, + tmp = (byte*)XREALLOC(*out, sz, front->heap, DYNAMIC_TYPE_TMP_BUFFER); if (tmp == NULL) { WOLFSSL_MSG("Memory error"); @@ -372,7 +372,9 @@ static int wolfSSL_BIO_BASE64_write(WOLFSSL_BIO* bio, const void* data, } } - XMEMCPY(*out, tmp, *outLen); + if (*out) { + XMEMCPY(*out, tmp, *outLen); + } XFREE(tmp, bio->heap, DYNAMIC_TYPE_TMP_BUFFER); /* Encode successful */