aboutsummaryrefslogtreecommitdiff
path: root/nxcomp
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-11-28 21:18:48 +0100
committerMihai Moldovan <ionic@ionic.de>2017-12-09 13:15:35 +0100
commit1c09eab703de18430241a11abec0526512d851b9 (patch)
tree9b84abf570d9f564567887b4760b409ff52945a3 /nxcomp
parentc4660e109aabc78abda4b80d637312385223537f (diff)
downloadnx-libs-1c09eab703de18430241a11abec0526512d851b9.tar.gz
nx-libs-1c09eab703de18430241a11abec0526512d851b9.tar.bz2
nx-libs-1c09eab703de18430241a11abec0526512d851b9.zip
Loop.cpp: fix two memleaks
Diffstat (limited to 'nxcomp')
-rw-r--r--nxcomp/src/Loop.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp
index b51d7e7e3..ca9e5ed08 100644
--- a/nxcomp/src/Loop.cpp
+++ b/nxcomp/src/Loop.cpp
@@ -4278,15 +4278,20 @@ int ListenConnectionTCP(const char *host, long port, const char *label)
int ListenConnection(ChannelEndPoint &endpoint, const char *label)
{
- char *unixPath, *host;
+ char *unixPath = NULL, *host = NULL;
long port;
+ int result = -1;
if (endpoint.getUnixPath(&unixPath)) {
- return ListenConnectionUnix(unixPath, label);
+ result = ListenConnectionUnix(unixPath, label);
}
else if (endpoint.getTCPHostAndPort(&host, &port)) {
- return ListenConnectionTCP(host, port, label);
+ result = ListenConnectionTCP(host, port, label);
}
- return -1;
+ free(unixPath);
+ unixPath = NULL;
+ free(host);
+ host = NULL;
+ return result;
}
static int AcceptConnection(int fd, int domain, const char *label)
@@ -6739,10 +6744,20 @@ int ConnectToRemote(ChannelEndPoint &socketAddress)
}
}
+ free(unixPath);
+ unixPath = NULL;
+ free(hostName);
+ hostName = NULL;
+
return pFD;
ConnectToRemoteError:
+ free(unixPath);
+ unixPath = NULL;
+ free(hostName);
+ hostName = NULL;
+
if (pFD != -1)
{
close(pFD);