fixup cf-socket to check errno only when the callback is not used

This commit is contained in:
Daniel Stenberg 2025-12-27 10:36:03 +01:00
parent 5c85b0dbf7
commit 0f608a3b76
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -346,14 +346,15 @@ static CURLcode socket_open(struct Curl_easy *data,
else {
/* opensocket callback not set, so simply create the socket now */
*sockfd = CURL_SOCKET(addr->family, addr->socktype, addr->protocol);
if((*sockfd == CURL_SOCKET_BAD) && (SOCKERRNO == SOCKENOMEM))
return CURLE_OUT_OF_MEMORY;
}
if(*sockfd == CURL_SOCKET_BAD) {
/* no socket, no connection */
failf(data, "failed to open socket: %s",
curlx_strerror(SOCKERRNO, errbuf, sizeof(errbuf)));
return SOCKERRNO == SOCKENOMEM ? CURLE_OUT_OF_MEMORY :
CURLE_COULDNT_CONNECT;
return CURLE_COULDNT_CONNECT;
}
#ifdef HAVE_FCNTL