Explorar o código

Fixed ssl_ctx not being freed at the time of error.
Closes https://github.com/espressif/esp-idf/issues/6143

Aditya Patwardhan %!s(int64=5) %!d(string=hai) anos
pai
achega
c707d0d323
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      components/esp_https_server/src/https_server.c

+ 3 - 0
components/esp_https_server/src/https_server.c

@@ -175,6 +175,7 @@ static httpd_ssl_ctx_t *create_secure_context(const struct httpd_ssl_config *con
         if (!cfg->cacert_buf) {
             ESP_LOGE(TAG, "Could not allocate memory");
             free(cfg);
+            free(ssl_ctx);
             return NULL;
         }
         memcpy((char *)cfg->cacert_buf, config->client_verify_cert_pem, config->client_verify_cert_len);
@@ -186,6 +187,7 @@ static httpd_ssl_ctx_t *create_secure_context(const struct httpd_ssl_config *con
         ESP_LOGE(TAG, "Could not allocate memory");
         free((void *)cfg->cacert_buf);
         free(cfg);
+        free(ssl_ctx);
         return NULL;
     }
     memcpy((char *)cfg->servercert_buf, config->cacert_pem, config->cacert_len);
@@ -197,6 +199,7 @@ static httpd_ssl_ctx_t *create_secure_context(const struct httpd_ssl_config *con
         free((void *)cfg->servercert_buf);
         free((void *)cfg->cacert_buf);
         free(cfg);
+        free(ssl_ctx);
         return NULL;
     }
     memcpy((char *)cfg->serverkey_buf, config->prvtkey_pem, config->prvtkey_len);