diff --git a/src/common/socket.cpp b/src/common/socket.cpp index eb971f952f..23276fb412 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -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;