mirror of
https://github.com/audacity/wxWidgets.git
synced 2025-12-10 03:58:56 -06:00
Avoid closing invalid socket after unsuccessful Accept()
Calling wxSocket::Accept() may return an invalid socket, especially when non-blocking, so don't close it unconditionally. This avoids an assertion failure in MSVC CRT due to calling closesocket() with an invalid argument.
This commit is contained in:
parent
56d36d11ba
commit
1d844882ed
@ -529,8 +529,6 @@ wxSocketImpl *wxSocketImpl::Accept(wxSocketBase& wxsocket)
|
||||
WX_SOCKLEN_T fromlen = sizeof(from);
|
||||
const wxSOCKET_T fd = accept(m_fd, &from.addr, &fromlen);
|
||||
|
||||
wxScopeGuard closeSocket = wxMakeGuard(wxCloseSocket, fd);
|
||||
|
||||
// accepting is similar to reading in the sense that it resets "ready for
|
||||
// read" flag on the socket
|
||||
ReenableEvents(wxSOCKET_INPUT_FLAG);
|
||||
@ -538,6 +536,8 @@ wxSocketImpl *wxSocketImpl::Accept(wxSocketBase& wxsocket)
|
||||
if ( fd == INVALID_SOCKET )
|
||||
return NULL;
|
||||
|
||||
wxScopeGuard closeSocket = wxMakeGuard(wxCloseSocket, fd);
|
||||
|
||||
wxSocketManager * const manager = wxSocketManager::Get();
|
||||
if ( !manager )
|
||||
return NULL;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user