summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-03-12 16:15:13 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-03-12 16:17:38 +0100
commite4636012e002fdad551d99906758d4cb47eb78bf (patch)
tree100554f0857de7a74085c956f5dedb5e6bc96f4f
parent43a56e34e15269bfb0fa5d7392b7fc171e77506d (diff)
downloadcurl-bagder/ftp-leak-done.tar.gz
ftp: fix memory leak in ftp_donebagder/ftp-leak-done
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
-rw-r--r--lib/ftp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 8b347e34f..5bf44f118 100644
--- 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