Skip to content

Commit

Permalink
ftp: fix memory leak in ftp_done
Browse files Browse the repository at this point in the history
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 curl#6737
  • Loading branch information
bagder committed Mar 12, 2021
1 parent d1f4007 commit 8ed71fc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ftp.c
Expand Up @@ -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
Expand Down

0 comments on commit 8ed71fc

Please sign in to comment.