Skip to content

Commit

Permalink
ftp: fix socket leak on rare error
Browse files Browse the repository at this point in the history
In the function AcceptServerConnect() the newly created socket would
leak if Curl_conn_tcp_accepted_set() returns error. Which basically
should never happen.

Spotted by CodeSonar.

Closes curl#13417
  • Loading branch information
bagder committed Apr 19, 2024
1 parent 0a25b3e commit b2523fc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,10 @@ static CURLcode AcceptServerConnect(struct Curl_easy *data)
(void)curlx_nonblock(s, TRUE); /* enable non-blocking */
/* Replace any filter on SECONDARY with one listening on this socket */
result = Curl_conn_tcp_accepted_set(data, conn, SECONDARYSOCKET, &s);
if(result)
if(result) {
sclose(s);
return result;
}

if(data->set.fsockopt) {
int error = 0;
Expand Down

0 comments on commit b2523fc

Please sign in to comment.