Close socket in case of errors in setting non-blocking

If configuring the newly created socket non-blocking fails we
error out and return INVALID_SOCKET, but the socket that had
been created wasn't closed. Fix by issuing closesocket in the
errorpath.

Backpatch to all supported branches.

Author: Ranier Vilela <ranier.vf@gmail.com>
Discussion: https://postgr.es/m/CAEudQApmU5CrKefH85VbNYE2y8H=-qqEJbg6RAPU65+vCe+89A@mail.gmail.com
Backpatch-through: v12
This commit is contained in:
Daniel Gustafsson 2024-01-17 11:24:11 +01:00
parent 44ad5129ce
commit 7cfa154d15
1 changed files with 1 additions and 0 deletions

View File

@ -303,6 +303,7 @@ pgwin32_socket(int af, int type, int protocol)
if (ioctlsocket(s, FIONBIO, &on))
{
TranslateSocketError();
closesocket(s);
return INVALID_SOCKET;
}
errno = 0;