Skip to content

Commit

Permalink
coap_digest_free: Handle NULL pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Nov 23, 2024
1 parent 1d465b6 commit 4c6ab62
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/coap_gnutls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/coap_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/coap_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/coap_wolfssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c6ab62

Please sign in to comment.