diff --git a/components/esp_http_client/lib/http_header.c b/components/esp_http_client/lib/http_header.c index 265bbbe7aa..ecb32693bb 100644 --- a/components/esp_http_client/lib/http_header.c +++ b/components/esp_http_client/lib/http_header.c @@ -97,6 +97,7 @@ static esp_err_t http_header_new_item(http_header_handle_t header, const char *k _header_new_item_exit: free(item->key); free(item->value); + free(item); return ESP_ERR_NO_MEM; } diff --git a/components/fatfs/src/ff.c b/components/fatfs/src/ff.c index 5ebdf49191..b00eebeace 100644 --- a/components/fatfs/src/ff.c +++ b/components/fatfs/src/ff.c @@ -5555,7 +5555,12 @@ FRESULT f_mkfs ( sz_buf = len / ss; /* Size of working buffer (sector) */ szb_buf = sz_buf * ss; /* Size of working buffer (byte) */ } - if (!buf || sz_buf == 0) return FR_NOT_ENOUGH_CORE; + if (!buf || sz_buf == 0) { +#if FF_USE_LFN == 3 + ff_memfree(buf); +#endif + return FR_NOT_ENOUGH_CORE; + } /* Determine where the volume to be located (b_vol, sz_vol) */ if (FF_MULTI_PARTITION && part != 0) { diff --git a/components/fatfs/src/vfs_fat.c b/components/fatfs/src/vfs_fat.c index ea74c82ee6..c6096026c7 100644 --- a/components/fatfs/src/vfs_fat.c +++ b/components/fatfs/src/vfs_fat.c @@ -557,12 +557,12 @@ static int vfs_fat_link(void* ctx, const char* n1, const char* n2) } fail3: f_close(pf2); - free(pf2); fail2: f_close(pf1); - free(pf1); fail1: free(buf); + free(pf2); + free(pf1); if (res != FR_OK) { ESP_LOGD(TAG, "%s: fresult=%d", __func__, res); errno = fresult_to_errno(res); diff --git a/components/tcp_transport/transport_ssl.c b/components/tcp_transport/transport_ssl.c index 40549c46e8..2443f81304 100644 --- a/components/tcp_transport/transport_ssl.c +++ b/components/tcp_transport/transport_ssl.c @@ -239,7 +239,10 @@ esp_transport_handle_t esp_transport_ssl_init() { esp_transport_handle_t t = esp_transport_init(); transport_ssl_t *ssl = calloc(1, sizeof(transport_ssl_t)); - ESP_TRANSPORT_MEM_CHECK(TAG, ssl, return NULL); + ESP_TRANSPORT_MEM_CHECK(TAG, ssl, { + esp_transport_destroy(t); + return NULL; + }); esp_transport_set_context_data(t, ssl); esp_transport_set_func(t, ssl_connect, ssl_read, ssl_write, ssl_close, ssl_poll_read, ssl_poll_write, ssl_destroy); esp_transport_set_async_connect_func(t, ssl_connect_async); diff --git a/components/tcp_transport/transport_tcp.c b/components/tcp_transport/transport_tcp.c index 3d5e7cb71b..74778bc2e8 100644 --- a/components/tcp_transport/transport_tcp.c +++ b/components/tcp_transport/transport_tcp.c @@ -226,7 +226,10 @@ esp_transport_handle_t esp_transport_tcp_init() { esp_transport_handle_t t = esp_transport_init(); transport_tcp_t *tcp = calloc(1, sizeof(transport_tcp_t)); - ESP_TRANSPORT_MEM_CHECK(TAG, tcp, return NULL); + ESP_TRANSPORT_MEM_CHECK(TAG, tcp, { + esp_transport_destroy(t); + return NULL; + }); tcp->sock = -1; esp_transport_set_func(t, tcp_connect, tcp_read, tcp_write, tcp_close, tcp_poll_read, tcp_poll_write, tcp_destroy); esp_transport_set_context_data(t, tcp); diff --git a/components/tcp_transport/transport_ws.c b/components/tcp_transport/transport_ws.c index 65f4a3e645..0be4894fc3 100644 --- a/components/tcp_transport/transport_ws.c +++ b/components/tcp_transport/transport_ws.c @@ -446,12 +446,14 @@ esp_transport_handle_t esp_transport_ws_init(esp_transport_handle_t parent_handl ws->path = strdup("/"); ESP_TRANSPORT_MEM_CHECK(TAG, ws->path, { free(ws); + esp_transport_destroy(t); return NULL; }); ws->buffer = malloc(DEFAULT_WS_BUFFER); ESP_TRANSPORT_MEM_CHECK(TAG, ws->buffer, { free(ws->path); free(ws); + esp_transport_destroy(t); return NULL; }); @@ -533,4 +535,4 @@ int esp_transport_ws_get_read_payload_len(esp_transport_handle_t t) { transport_ws_t *ws = esp_transport_get_context_data(t); return ws->frame_state.payload_len; -} \ No newline at end of file +} diff --git a/components/wifi_provisioning/src/wifi_config.c b/components/wifi_provisioning/src/wifi_config.c index 93e3e85643..165c3f05df 100644 --- a/components/wifi_provisioning/src/wifi_config.c +++ b/components/wifi_provisioning/src/wifi_config.c @@ -83,6 +83,7 @@ static esp_err_t cmd_get_status_handler(WiFiConfigPayload *req, malloc(sizeof(WifiConnectedState))); if (!connected) { ESP_LOGE(TAG, "Error allocating memory"); + free(resp_payload); return ESP_ERR_NO_MEM; } resp_payload->connected = connected;