summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-17 16:08:58 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-17 16:08:58 +0300
commitfd7566b5de6b59bb18ff380cb1fa3f3f1089b70b (patch)
tree6c13eed0ce8f92ad65e5613f0d30c15f3102ca76
parenta61f99f45ad4707f1654544d2ba6438a8556815c (diff)
code cleaning
-rw-r--r--src/mir_app/src/netlibbind.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mir_app/src/netlibbind.cpp b/src/mir_app/src/netlibbind.cpp
index bbc9c6fee3..ad7c160bbe 100644
--- a/src/mir_app/src/netlibbind.cpp
+++ b/src/mir_app/src/netlibbind.cpp
@@ -179,9 +179,10 @@ MIR_APP_DLL(HNETLIBBIND) Netlib_BindPort(HNETLIBUSER nlu, NETLIBBIND *nlb)
return nullptr;
}
- NetlibBoundPort *nlbp = (NetlibBoundPort*)mir_calloc(sizeof(NetlibBoundPort));
+ NetlibBoundPort *nlbp = new NetlibBoundPort(nlu, nlb);
if (nlbp->s == INVALID_SOCKET && nlbp->s6 == INVALID_SOCKET) {
Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "socket", WSAGetLastError());
+LBL_Error:
delete nlbp;
return nullptr;
}
@@ -226,9 +227,7 @@ MIR_APP_DLL(HNETLIBBIND) Netlib_BindPort(HNETLIBUSER nlu, NETLIBBIND *nlb)
}
if (!foundPort) {
Netlib_Logf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "bind", WSAGetLastError());
-LBL_Error:
- delete nlbp;
- return nullptr;
+ goto LBL_Error;
}
if (nlbp->s != INVALID_SOCKET && listen(nlbp->s, 5)) {
@@ -300,6 +299,8 @@ NetlibBoundPort::NetlibBoundPort(HNETLIBUSER _nlu, NETLIBBIND *nlb)
NetlibBoundPort::~NetlibBoundPort()
{
- closesocket(s);
- closesocket(s6);
+ if (s != INVALID_SOCKET)
+ closesocket(s);
+ if (s6 != INVALID_SOCKET)
+ closesocket(s6);
}