ftp: fix socket leak on rare error

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 #13417
This commit is contained in:
Daniel Stenberg 2024-04-19 09:13:42 +02:00
parent 0a25b3e014
commit b2523fc439
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -388,8 +388,10 @@ static CURLcode AcceptServerConnect(struct Curl_easy *data)
(void)curlx_nonblock(s, TRUE); /* enable non-blocking */ (void)curlx_nonblock(s, TRUE); /* enable non-blocking */
/* Replace any filter on SECONDARY with one listening on this socket */ /* Replace any filter on SECONDARY with one listening on this socket */
result = Curl_conn_tcp_accepted_set(data, conn, SECONDARYSOCKET, &s); result = Curl_conn_tcp_accepted_set(data, conn, SECONDARYSOCKET, &s);
if(result) if(result) {
sclose(s);
return result; return result;
}
if(data->set.fsockopt) { if(data->set.fsockopt) {
int error = 0; int error = 0;