From 3a69b1d94f3f2d2608486f42f59804cd955ed639 Mon Sep 17 00:00:00 2001 From: Nicklas Frahm Date: Sat, 12 Mar 2022 12:27:30 +0100 Subject: [PATCH] esp_http_client: fix redirect by resetting location before parsing Closes #8563. Signed-off-by: Nicklas Frahm --- components/esp_http_client/esp_http_client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/esp_http_client/esp_http_client.c b/components/esp_http_client/esp_http_client.c index 24aab489b6..c9fa4bd47b 100644 --- a/components/esp_http_client/esp_http_client.c +++ b/components/esp_http_client/esp_http_client.c @@ -527,6 +527,10 @@ 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; + if (client->location != NULL) { + free(client->location); + client->location = NULL; + } http_parser_init(client->parser, HTTP_RESPONSE); if (client->connection_info.username) { char *auth_response = NULL;