esp-tls: Fix mem leak when global_ca_store is freed

This commit is contained in:
Aditya Patwardhan
2021-01-21 11:31:52 +05:30
parent 38ea44faaf
commit 4df95abb22

View File

@@ -193,6 +193,7 @@ esp_err_t esp_tls_set_global_ca_store(const unsigned char *cacert_pem_buf, const
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) {
@@ -211,6 +212,7 @@ void esp_tls_free_global_ca_store()
{
if (global_cacert) {
mbedtls_x509_crt_free(global_cacert);
free(global_cacert);
global_cacert = NULL;
}
}