[X2Go-Commits] [nx-libs] 15/19: ChannelEndPoint.cpp: fix possible memleak in getUnixPath()

git-admin at x2go.org git-admin at x2go.org
Sat Dec 30 03:35:16 CET 2017


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch 3.6.x
in repository nx-libs.

commit ce293647d5a63726c05260ca0e0f65a50e604ebb
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Wed Dec 27 19:16:15 2017 +0100

    ChannelEndPoint.cpp: fix possible memleak in getUnixPath()
---
 nxcomp/src/ChannelEndPoint.cpp | 8 +++++---
 nxcomp/src/Loop.cpp            | 1 +
 nxcomp/src/Proxy.cpp           | 2 +-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/nxcomp/src/ChannelEndPoint.cpp b/nxcomp/src/ChannelEndPoint.cpp
index 443c0f2..7768df1 100644
--- a/nxcomp/src/ChannelEndPoint.cpp
+++ b/nxcomp/src/ChannelEndPoint.cpp
@@ -207,7 +207,10 @@ ChannelEndPoint::getPort(long *port) const {
 bool
 ChannelEndPoint::getUnixPath(char **unixPath) const {
 
-  if (unixPath) *unixPath = NULL;
+  if (unixPath)
+    *unixPath = NULL;
+  else
+    return false;
 
   long p;
   char *path = NULL;
@@ -227,8 +230,7 @@ ChannelEndPoint::getUnixPath(char **unixPath) const {
       return false;
   }
 
-  if (unixPath)
-    *unixPath = strdup(path);
+  *unixPath = strdup(path);
 
   return true;
 }
diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp
index ab7ea5a..1e77038 100644
--- a/nxcomp/src/Loop.cpp
+++ b/nxcomp/src/Loop.cpp
@@ -6661,6 +6661,7 @@ int ConnectToRemote(ChannelEndPoint &socketAddress)
           << "'.\n" << std::flush;
 
     SAFE_FREE(hostName);
+    SAFE_FREE(unixPath);
 
     if (socketAddress.getUnixPath(&unixPath))
       result = PrepareProxyConnectionUnix(&unixPath, &connectTimeout, &pFD, &reason);
diff --git a/nxcomp/src/Proxy.cpp b/nxcomp/src/Proxy.cpp
index 71ea090..7f72fae 100644
--- a/nxcomp/src/Proxy.cpp
+++ b/nxcomp/src/Proxy.cpp
@@ -6123,7 +6123,7 @@ int Proxy::handleNewSlaveConnection(int clientFd)
 int Proxy::handleNewGenericConnectionFromProxy(int channelId, T_channel_type type,
                                                ChannelEndPoint &endPoint, const char *label)
 {
-  char *unixPath, *host = NULL;
+  char *unixPath = NULL, *host = NULL;
   long port;
 
   if (endPoint.getUnixPath(&unixPath)) {

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list