diff --git a/src/ssl.c b/src/ssl.c index e1cb598966..afd505027a 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -13566,7 +13566,9 @@ WOLFSSL_STACK* wolfSSL_sk_new_node(void* heap) /* free's node but does not free internal data such as in->data.x509 */ void wolfSSL_sk_free_node(WOLFSSL_STACK* in) { - XFREE(in, in->heap, DYNAMIC_TYPE_OPENSSL); + if (in != NULL) { + XFREE(in, in->heap, DYNAMIC_TYPE_OPENSSL); + } } /* pushes node "in" onto "stack" and returns pointer to the new stack on success diff --git a/src/x509.c b/src/x509.c index e34e6b7ab1..2e443a023a 100644 --- a/src/x509.c +++ b/src/x509.c @@ -9684,7 +9684,9 @@ WOLF_STACK_OF(WOLFSSL_X509)* wolfSSL_X509_chain_up_ref( { WOLFSSL_ENTER("wolfSSL_X509_NAME_free"); FreeX509Name(name); - XFREE(name, name->heap, DYNAMIC_TYPE_X509); + if (name != NULL) { + XFREE(name, name->heap, DYNAMIC_TYPE_X509); + } } diff --git a/wolfcrypt/src/evp.c b/wolfcrypt/src/evp.c index 813a4a275c..8b78f620c6 100644 --- a/wolfcrypt/src/evp.c +++ b/wolfcrypt/src/evp.c @@ -12282,7 +12282,9 @@ struct WOLFSSL_EVP_ENCODE_CTX* wolfSSL_EVP_ENCODE_CTX_new(void) void wolfSSL_EVP_ENCODE_CTX_free(WOLFSSL_EVP_ENCODE_CTX* ctx) { WOLFSSL_ENTER("wolfSSL_EVP_ENCODE_CTX_free"); - XFREE(ctx, ctx->heap, DYNAMIC_TYPE_OPENSSL); + if (ctx != NULL) { + XFREE(ctx, ctx->heap, DYNAMIC_TYPE_OPENSSL); + } } #endif /* WOLFSSL_BASE64_ENCODE || WOLFSSL_BASE64_DECODE */ #if defined(WOLFSSL_BASE64_ENCODE)