From fef1fc0d32455fe4d04250862bce607900c1439e Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Fri, 11 May 2001 06:10:48 +0000
Subject: [PATCH] Ingo Wilken's redirect fixes

---
 lib/transfer.c | 1 +
 lib/url.c      | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/lib/transfer.c b/lib/transfer.c
index 5823921484..1dad615f4c 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -910,6 +910,7 @@ CURLcode Curl_perform(CURL *curl)
       
         /* TBD: set the URL with curl_setopt() */
         data->url = newurl;
+        newurl = NULL; /* don't free! */
 
         data->bits.urlstringalloc = TRUE; /* the URL is allocated */
 
diff --git a/lib/url.c b/lib/url.c
index 8c23ae9983..787bc18bef 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2233,6 +2233,12 @@ CURLcode Curl_done(struct connectdata *conn)
     conn->bits.rangestringalloc = FALSE;
   }
 
+  /* Cleanup possible redirect junk */
+  if(conn->newurl) {
+    free(conn->newurl);
+    conn->newurl = NULL;
+  }
+ 
   /* this calls the protocol-specific function pointer previously set */
   if(conn->curl_done)
     result = conn->curl_done(conn);
-- 
GitLab