fix(esp_http_server): fix GCC 14 analyzer warnings

This commit is contained in:
Alexey Lapshin 2024-09-04 11:08:44 +07:00
parent 725b9ec81e
commit a262e879d1

View File

@ -146,11 +146,13 @@ esp_err_t httpd_register_uri_handler(httpd_handle_t handle,
for (int i = 0; i < hd->config.max_uri_handlers; i++) { for (int i = 0; i < hd->config.max_uri_handlers; i++) {
if (hd->hd_calls[i] == NULL) { if (hd->hd_calls[i] == NULL) {
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak") // False-positive detection. TODO GCC-366
hd->hd_calls[i] = malloc(sizeof(httpd_uri_t)); hd->hd_calls[i] = malloc(sizeof(httpd_uri_t));
if (hd->hd_calls[i] == NULL) { if (hd->hd_calls[i] == NULL) {
/* Failed to allocate memory */ /* Failed to allocate memory */
return ESP_ERR_HTTPD_ALLOC_MEM; return ESP_ERR_HTTPD_ALLOC_MEM;
} }
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak")
/* Copy URI string */ /* Copy URI string */
hd->hd_calls[i]->uri = strdup(uri_handler->uri); hd->hd_calls[i]->uri = strdup(uri_handler->uri);