From fd33d025639a0d754fa3ac9c256e475d8bb7e4c9 Mon Sep 17 00:00:00 2001 From: Salvatore Mesoraca Date: Thu, 28 Aug 2025 00:50:30 +0200 Subject: [PATCH] fix(esp_http_server): fix memory leak in httpd_req_async_handler_begin Free scratch memory when response headers allocation fails --- components/esp_http_server/src/httpd_txrx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/esp_http_server/src/httpd_txrx.c b/components/esp_http_server/src/httpd_txrx.c index 1404d4f994..475eb84fea 100644 --- a/components/esp_http_server/src/httpd_txrx.c +++ b/components/esp_http_server/src/httpd_txrx.c @@ -675,6 +675,7 @@ esp_err_t httpd_req_async_handler_begin(httpd_req_t *r, httpd_req_t **out) async_aux->resp_hdrs = calloc(hd->config.max_resp_headers, sizeof(struct resp_hdr)); if (async_aux->resp_hdrs == NULL) { + free(async_aux->scratch); free(async_aux); free(async); return ESP_ERR_NO_MEM;