Cygwin: accept4: Fix resource leak

The new implementation neglected to release the file descriptor
in case of error.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2018-03-02 23:33:05 +01:00
parent 984c8beeff
commit 00e8707830
2 changed files with 4 additions and 0 deletions

View File

@ -895,6 +895,8 @@ fhandler_socket_inet::accept4 (struct sockaddr *peer, int *len, int flags)
*len = llen; *len = llen;
} }
} }
else
fd.release ();
} }
if (ret == -1) if (ret == -1)
::closesocket (res); ::closesocket (res);

View File

@ -1012,6 +1012,8 @@ fhandler_socket_local::accept4 (struct sockaddr *peer, int *len, int flags)
*len = (int) sizeof (un.sun_family); *len = (int) sizeof (un.sun_family);
} }
} }
else
fd.release ();
} }
if (ret == -1) if (ret == -1)
::closesocket (res); ::closesocket (res);