esp-tls: Fix mem leak when global_ca_store is freed

This commit is contained in:
Aditya Patwardhan 2020-12-26 12:43:12 +05:30 committed by bot
parent fe8a891de9
commit cddb8c29e6

View File

@ -639,6 +639,7 @@ esp_err_t esp_mbedtls_set_global_ca_store(const unsigned char *cacert_pem_buf, c
if (ret < 0) {
ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x", -ret);
mbedtls_x509_crt_free(global_cacert);
free(global_cacert);
global_cacert = NULL;
return ESP_FAIL;
} else if (ret > 0) {
@ -657,6 +658,7 @@ void esp_mbedtls_free_global_ca_store(void)
{
if (global_cacert) {
mbedtls_x509_crt_free(global_cacert);
free(global_cacert);
global_cacert = NULL;
}
}