Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r--winsup/cygwin/net.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index 06b9a5acb..b775fb9a7 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -521,6 +521,8 @@ fdsock (int &fd, const char *name, SOCKET soc)
winsock2_active);
fhandler_socket *fh =
(fhandler_socket *) cygheap->fdtab.build_fhandler (fd, FH_SOCKET, name);
+ if (!fh)
+ return NULL;
fh->set_io_handle ((HANDLE) soc);
fh->set_flags (O_RDWR | O_BINARY);
fh->set_r_no_interrupt (winsock2_active);
@@ -558,12 +560,17 @@ cygwin_socket (int af, int type, int protocol)
name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket");
fh = fdsock (fd, name, soc);
- if (fh)
+ if (!fh)
+ {
+ closesocket (soc);
+ res = -1;
+ }
+ else
{
fh->set_addr_family (af);
fh->set_socket_type (type);
+ res = fd;
}
- res = fd;
}
done: