From c4660e109aabc78abda4b80d637312385223537f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 28 Nov 2017 20:43:44 +0100 Subject: ChannelEndPoint.cpp: fix two memleaks --- nxcomp/src/ChannelEndPoint.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'nxcomp') diff --git a/nxcomp/src/ChannelEndPoint.cpp b/nxcomp/src/ChannelEndPoint.cpp index 8cc0c1d41..843bf2b35 100644 --- a/nxcomp/src/ChannelEndPoint.cpp +++ b/nxcomp/src/ChannelEndPoint.cpp @@ -54,6 +54,12 @@ ChannelEndPoint::~ChannelEndPoint() if(S_ISSOCK(st.st_mode)) unlink(unixPath); } + free(unixPath); + unixPath = NULL; + free(defaultUnixPath_); + defaultUnixPath_ = NULL; + free(spec_); + spec_ = NULL; } void @@ -90,12 +96,12 @@ void ChannelEndPoint::setSpec(const char *hostName, long port) { int length; - free(spec_); - spec_ = NULL; - isUnix_ = false; isTCP_ = false; + free(spec_); + spec_ = NULL; + if (hostName && strlen(hostName) && port >= 1) { length = snprintf(NULL, 0, "tcp:%s:%ld", hostName, port); @@ -195,7 +201,7 @@ ChannelEndPoint::getPort(long *port) const { bool ChannelEndPoint::getUnixPath(char **unixPath) const { - if (unixPath) *unixPath = 0; + if (unixPath) *unixPath = NULL; long p; char *path = NULL; -- cgit v1.2.3