mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
http-client: fix memory allocation issues found by static analyser
This commit is contained in:
parent
695f075a13
commit
917192725a
@ -621,14 +621,22 @@ esp_err_t esp_http_client_cleanup(esp_http_client_handle_t client)
|
||||
}
|
||||
esp_http_client_close(client);
|
||||
esp_transport_list_destroy(client->transport_list);
|
||||
http_header_destroy(client->request->headers);
|
||||
free(client->request->buffer->data);
|
||||
free(client->request->buffer);
|
||||
free(client->request);
|
||||
http_header_destroy(client->response->headers);
|
||||
free(client->response->buffer->data);
|
||||
free(client->response->buffer);
|
||||
free(client->response);
|
||||
if (client->request) {
|
||||
http_header_destroy(client->request->headers);
|
||||
if (client->request->buffer) {
|
||||
free(client->request->buffer->data);
|
||||
}
|
||||
free(client->request->buffer);
|
||||
free(client->request);
|
||||
}
|
||||
if (client->response) {
|
||||
http_header_destroy(client->response->headers);
|
||||
if (client->response->buffer) {
|
||||
free(client->response->buffer->data);
|
||||
}
|
||||
free(client->response->buffer);
|
||||
free(client->response);
|
||||
}
|
||||
|
||||
free(client->parser);
|
||||
free(client->parser_settings);
|
||||
@ -700,7 +708,10 @@ esp_err_t esp_http_client_set_url(esp_http_client_handle_t client, const char *u
|
||||
|
||||
if (purl.field_data[UF_HOST].len) {
|
||||
http_utils_assign_string(&client->connection_info.host, url + purl.field_data[UF_HOST].off, purl.field_data[UF_HOST].len);
|
||||
HTTP_MEM_CHECK(TAG, client->connection_info.host, return ESP_ERR_NO_MEM);
|
||||
HTTP_MEM_CHECK(TAG, client->connection_info.host, {
|
||||
free(old_host);
|
||||
return ESP_ERR_NO_MEM;
|
||||
});
|
||||
}
|
||||
// Close the connection if host was changed
|
||||
if (old_host && client->connection_info.host
|
||||
|
Loading…
x
Reference in New Issue
Block a user