]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftp: fix memory leak in ftp_done
authorDaniel Stenberg <daniel@haxx.se>
Fri, 12 Mar 2021 15:15:13 +0000 (16:15 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 12 Mar 2021 18:53:05 +0000 (19:53 +0100)
If after a transfer is complete Curl_GetFTPResponse() returns an error,
curl would not free the ftp->pathalloc block.

Found by torture-testing test 576

Closes #6737

lib/ftp.c

index 8b347e34fda5a33df5de069495d5bfb25439daa0..5bf44f1180ec211c2c760cf08fbdff17ea735277 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -3325,8 +3325,10 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status,
       connclose(conn, "Timeout or similar in FTP DONE operation"); /* close */
     }
 
-    if(result)
+    if(result) {
+      Curl_safefree(ftp->pathalloc);
       return result;
+    }
 
     if(ftpc->dont_check && data->req.maxdownload > 0) {
       /* we have just sent ABOR and there is no reliable way to check if it was