httpclient: only free challenges for current_server type Prior to this commit we freed both the server and proxy auth challenges in git_http_client_read_response. This works when the proxy needs auth or when the server needs auth, but it does not work when both the proxy and the server need auth as we erroneously remove the server auth challenge before we have added them as server credentials. Instead only remove the challenges for the current_server type. Co-authored-by: Stephen Gelman <ssgelm@gmail.com>
diff --git a/src/transports/httpclient.c b/src/transports/httpclient.c
index dda2678..7152130 100644
--- a/src/transports/httpclient.c
+++ b/src/transports/httpclient.c
@@ -1374,8 +1374,11 @@ int git_http_client_read_response(
git_http_response_dispose(response);
- git_vector_free_deep(&client->server.auth_challenges);
- git_vector_free_deep(&client->proxy.auth_challenges);
+ if (client->current_server == PROXY) {
+ git_vector_free_deep(&client->proxy.auth_challenges);
+ } else if(client->current_server == SERVER) {
+ git_vector_free_deep(&client->server.auth_challenges);
+ }
client->state = READING_RESPONSE;
client->keepalive = 0;