From: Daniel Stenberg Date: Fri, 12 Mar 2021 15:15:13 +0000 (+0100) Subject: ftp: fix memory leak in ftp_done X-Git-Tag: curl-7_76_0~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ed71fc4f7116288da75ed85e21fe8c53f4cdfb2;p=thirdparty%2Fcurl.git ftp: fix memory leak in ftp_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 Closes #6737 --- diff --git a/lib/ftp.c b/lib/ftp.c index 8b347e34fd..5bf44f1180 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