diff options
-rw-r--r-- | nxcomp/src/Loop.cpp | 23 |
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); |