Skip to content

Commit d3cb2b8

Browse files
committed
Merge pull request #4551
c994d2e prevent SOCKET leak in BindListenPort() (Philip Kaufmann)
2 parents a2404ce + c994d2e commit d3cb2b8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/net.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,7 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
16781678
else
16791679
strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)"), addrBind.ToString(), NetworkErrorString(nErr));
16801680
LogPrintf("%s\n", strError);
1681+
CloseSocket(hListenSocket);
16811682
return false;
16821683
}
16831684
LogPrintf("Bound to %s\n", addrBind.ToString());
@@ -1687,6 +1688,7 @@ bool BindListenPort(const CService &addrBind, string& strError, bool fWhiteliste
16871688
{
16881689
strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)"), NetworkErrorString(WSAGetLastError()));
16891690
LogPrintf("%s\n", strError);
1691+
CloseSocket(hListenSocket);
16901692
return false;
16911693
}
16921694

0 commit comments

Comments
 (0)