aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-09-03 22:22:02 -0700
committerH. Peter Anvin <hpa@zytor.com>2018-09-03 22:22:02 -0700
commit26c1defaad14ef6c43cbed08bac46cfc32b1f4c8 (patch)
tree980a4db64d73922155afe7f563f4d43c45b2ddaa
parent3bbec528eb74d0ed0f5b3d3c5803cbf81de2aaba (diff)
downloadgrv-26c1defaad14ef6c43cbed08bac46cfc32b1f4c8.tar.gz
grv-26c1defaad14ef6c43cbed08bac46cfc32b1f4c8.tar.xz
grv-26c1defaad14ef6c43cbed08bac46cfc32b1f4c8.zip
netopen, win32: if _open_osfhandle fails, close the *socket*
If _open_osfhandle() fails, then we need to close the socket, not the non-existent file descriptor. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--netopen.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/netopen.c b/netopen.c
index 31832c3..0e72fdb 100644
--- a/netopen.c
+++ b/netopen.c
@@ -47,7 +47,7 @@ static FILE *sock_to_file(SOCKET sock, int is_write)
fd = _open_osfhandle(&osfhandle, is_write ? 0 : _O_RDONLY);
if (fd < 0) {
- closesocket(fd);
+ closesocket(sock);
return NULL;
}