#6037 socket accept() failure could lead to NULL ptr dereference

This commit is contained in:
Andrew Nelless 2017-05-12 00:10:16 +01:00
parent 1c5e986dcf
commit 485540bbb4
1 changed files with 7 additions and 3 deletions

View File

@ -311,7 +311,7 @@ ArchNetworkWinsock::listenOnSocket(ArchSocket s)
} }
ArchSocket ArchSocket
ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress* addr) ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress* const addr)
{ {
assert(s != NULL); assert(s != NULL);
@ -325,7 +325,9 @@ ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress* addr)
int err = getsockerror_winsock(); int err = getsockerror_winsock();
delete socket; delete socket;
free(tmp); free(tmp);
*addr = NULL; if (addr) {
*addr = NULL;
}
if (err == WSAEWOULDBLOCK) { if (err == WSAEWOULDBLOCK) {
return NULL; return NULL;
} }
@ -339,7 +341,9 @@ ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress* addr)
close_winsock(fd); close_winsock(fd);
delete socket; delete socket;
free(tmp); free(tmp);
*addr = NULL; if (addr) {
*addr = NULL;
}
throw; throw;
} }