Skip to content

Commit

Permalink
coap_mbedtls.c: Fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 authored and obgm committed Jun 27, 2022
1 parent e8052b3 commit 8b9377e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/coap_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,8 @@ set_ciphersuites(mbedtls_ssl_config *conf, coap_enc_method_t method)
pki_ciphers = mbedtls_malloc(pki_count * sizeof(pki_ciphers[0]));
if (pki_ciphers == NULL) {
coap_log(LOG_ERR, "set_ciphers: mbedtls_malloc with count %d failed\n", pki_count);
mbedtls_free(psk_ciphers);
psk_ciphers = NULL;
return;
}

Expand Down Expand Up @@ -2384,6 +2386,13 @@ void coap_dtls_startup(void)
}

void coap_dtls_shutdown(void) {
#if COAP_CLIENT_SUPPORT
mbedtls_free(psk_ciphers);
mbedtls_free(pki_ciphers);
psk_ciphers = NULL;
pki_ciphers = NULL;
processed_ciphers = 0;
#endif /* COAP_CLIENT_SUPPORT */
}

void *
Expand Down

0 comments on commit 8b9377e

Please sign in to comment.