From b4456bff97aab4e4dcef3d7a6f80d5d3196e3c43 Mon Sep 17 00:00:00 2001 From: Shubham Kulkarni Date: Thu, 17 Mar 2022 09:59:29 +0530 Subject: [PATCH] esp_http_client: Add comment for clearing location field in esp_http_client_prepare --- components/esp_http_client/esp_http_client.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index 52142c158b..b66fa0e166 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -512,6 +512,12 @@ static esp_err_t esp_http_client_prepare(esp_http_client_handle_t client) client->process_again = 0; client->response->data_process = 0; client->first_line_prepared = false; + /** + * Clear location field before making a new HTTP request. Location + * field should not be cleared in http_on_header* callbacks because + * callbacks can be invoked multiple times for same header, and + * hence can lead to data corruption. + */ if (client->location != NULL) { free(client->location); client->location = NULL;