diff --git a/src/coap_gnutls.c b/src/coap_gnutls.c index 8cf73bfa..0a693eaa 100644 --- a/src/coap_gnutls.c +++ b/src/coap_gnutls.c @@ -2964,7 +2964,8 @@ coap_digest_setup(void) { void coap_digest_free(coap_digest_ctx_t *digest_ctx) { - gnutls_hash_deinit(digest_ctx, NULL); + if (digest_ctx) + gnutls_hash_deinit(digest_ctx, NULL); } int diff --git a/src/coap_mbedtls.c b/src/coap_mbedtls.c index a4f55659..0106b71e 100644 --- a/src/coap_mbedtls.c +++ b/src/coap_mbedtls.c @@ -2880,8 +2880,10 @@ coap_digest_setup(void) { void coap_digest_free(coap_digest_ctx_t *digest_ctx) { - mbedtls_sha256_free(digest_ctx); - mbedtls_free(digest_ctx); + if (digest_ctx) { + mbedtls_sha256_free(digest_ctx); + mbedtls_free(digest_ctx); + } } int diff --git a/src/coap_openssl.c b/src/coap_openssl.c index a8ed48eb..5e589e78 100644 --- a/src/coap_openssl.c +++ b/src/coap_openssl.c @@ -4082,7 +4082,8 @@ coap_digest_setup(void) { void coap_digest_free(coap_digest_ctx_t *digest_ctx) { - EVP_MD_CTX_free(digest_ctx); + if (digest_ctx) + EVP_MD_CTX_free(digest_ctx); } int diff --git a/src/coap_wolfssl.c b/src/coap_wolfssl.c index 4c2083a5..b3faa09d 100644 --- a/src/coap_wolfssl.c +++ b/src/coap_wolfssl.c @@ -2859,7 +2859,8 @@ coap_digest_setup(void) { void coap_digest_free(coap_digest_ctx_t *digest_ctx) { - wolfSSL_EVP_MD_CTX_free(digest_ctx); + if (digest_ctx) + wolfSSL_EVP_MD_CTX_free(digest_ctx); } int