Merge branch 'fix/esp_tls_fix_memory_leak_v4.1' into 'release/v4.1'

esp-tls: Fix mem leak when global_ca_store is freed

See merge request espressif/esp-idf!12086
This commit is contained in:
Mahavir Jain 2021-01-29 20:34:11 +08:00
commit 744948e189

View File

@ -532,6 +532,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) {
@ -550,6 +551,7 @@ void esp_mbedtls_free_global_ca_store(void)
{
if (global_cacert) {
mbedtls_x509_crt_free(global_cacert);
free(global_cacert);
global_cacert = NULL;
}
}