diff options
| author | Philip Kaufmann <[email protected]> | 2014-07-17 22:33:58 +0200 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2015-06-27 14:11:36 +0000 |
| commit | c118e9d275e4955870aed82f20355c76a85b1c54 (patch) | |
| tree | 5d42d614de4cbbc84a1dc4c3dc8168d1ee29bcd2 /src/net.cpp | |
| parent | Convert closesocket 'compat wrapper' to function in netbase (diff) | |
| download | discoin-c118e9d275e4955870aed82f20355c76a85b1c54.tar.xz discoin-c118e9d275e4955870aed82f20355c76a85b1c54.zip | |
prevent SOCKET leak in BindListenPort()
- the call to CloseSocket() is placed after the WSAGetLastError(), because
a CloseSocket() can trigger an error also, which we don't want for the
logging in this two cases
Diffstat (limited to 'src/net.cpp')
| -rw-r--r-- | src/net.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp index d4a526cd4..97bb52cd3 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1671,6 +1671,7 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste else strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)"), addrBind.ToString(), NetworkErrorString(nErr)); LogPrintf("%s\n", strError); + CloseSocket(hListenSocket); return false; } LogPrintf("Bound to %s\n", addrBind.ToString()); @@ -1680,6 +1681,7 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste { strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)"), NetworkErrorString(WSAGetLastError())); LogPrintf("%s\n", strError); + CloseSocket(hListenSocket); return false; } |