Merge branch 'contrib/github_pr_13945_v5.0' into 'release/v5.0'

fix(esp_http_client): Do not allocate client->if_name twice in esp_http_client_init. (GitHub PR) (v5.0)

See merge request espressif/esp-idf!31945
This commit is contained in:
Mahavir Jain 2024-07-10 13:53:03 +08:00
commit 6a284148f3

View File

@ -581,9 +581,11 @@ static bool init_common_tcp_transport(esp_http_client_handle_t client, const esp
} }
if (config->if_name) { if (config->if_name) {
client->if_name = calloc(1, sizeof(struct ifreq)); if (client->if_name == NULL) {
ESP_RETURN_ON_FALSE(client->if_name, false, TAG, "Memory exhausted"); client->if_name = calloc(1, sizeof(struct ifreq));
memcpy(client->if_name, config->if_name, sizeof(struct ifreq)); ESP_RETURN_ON_FALSE(client->if_name, false, TAG, "Memory exhausted");
memcpy(client->if_name, config->if_name, sizeof(struct ifreq));
}
esp_transport_tcp_set_interface_name(transport, client->if_name); esp_transport_tcp_set_interface_name(transport, client->if_name);
} }
return true; return true;