From 428f94b5411bf51b6e77d611daa709dfbb063966 Mon Sep 17 00:00:00 2001 From: gades Date: Sun, 23 Nov 2014 19:18:03 +0200 Subject: [PATCH] prevent SOCKET leak in BindListenPort() Conflicts: src/net.cpp --- src/compat.h | 1 - src/net.cpp | 2 ++ 2 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/compat.h b/src/compat.h index 67fe63d..c38e2fa 100644 --- a/src/compat.h +++ b/src/compat.h @@ -70,5 +70,4 @@ inline int myclosesocket(SOCKET& hSocket) } #define closesocket(s) myclosesocket(s) - #endif diff --git a/src/net.cpp b/src/net.cpp index 698c4d4..ab079cf 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1808,6 +1808,7 @@ bool BindListenPort(const CService &addrBind, string& strError) else strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %d, %s)"), addrBind.ToString().c_str(), nErr, strerror(nErr)); printf("%s\n", strError.c_str()); + closesocket(hListenSocket); return false; } printf("Bound to %s\n", addrBind.ToString().c_str()); @@ -1817,6 +1818,7 @@ bool BindListenPort(const CService &addrBind, string& strError) { strError = strprintf("Error: Listening for incoming connections failed (listen returned error %d)", WSAGetLastError()); printf("%s\n", strError.c_str()); + closesocket(hListenSocket); return false; } -- 1.7.1