mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp-tls: Fix mem leak when global_ca_store is freed
This commit is contained in:
parent
56de4bbc4d
commit
a5cf243ea0
@ -578,6 +578,7 @@ esp_err_t esp_mbedtls_set_global_ca_store(const unsigned char *cacert_pem_buf, c
|
|||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x", -ret);
|
ESP_LOGE(TAG, "mbedtls_x509_crt_parse returned -0x%x", -ret);
|
||||||
mbedtls_x509_crt_free(global_cacert);
|
mbedtls_x509_crt_free(global_cacert);
|
||||||
|
free(global_cacert);
|
||||||
global_cacert = NULL;
|
global_cacert = NULL;
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
} else if (ret > 0) {
|
} else if (ret > 0) {
|
||||||
@ -596,6 +597,7 @@ void esp_mbedtls_free_global_ca_store(void)
|
|||||||
{
|
{
|
||||||
if (global_cacert) {
|
if (global_cacert) {
|
||||||
mbedtls_x509_crt_free(global_cacert);
|
mbedtls_x509_crt_free(global_cacert);
|
||||||
|
free(global_cacert);
|
||||||
global_cacert = NULL;
|
global_cacert = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user