[X2Go-Commits] [nx-libs] 05/19: ChannelEndPoint.cpp: re-scope/improve getSpec

git-admin at x2go.org git-admin at x2go.org
Sat Dec 30 03:35:15 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 c48748ba0929a488437d85732032aef78528093b
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Wed Dec 27 12:18:28 2017 +0100

    ChannelEndPoint.cpp: re-scope/improve getSpec
---
 nxcomp/src/ChannelEndPoint.cpp | 28 +++++++++++++++++++---------
 nxcomp/src/Loop.cpp            |  2 ++
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/nxcomp/src/ChannelEndPoint.cpp b/nxcomp/src/ChannelEndPoint.cpp
index a1d9608..2abc0ee 100644
--- a/nxcomp/src/ChannelEndPoint.cpp
+++ b/nxcomp/src/ChannelEndPoint.cpp
@@ -113,13 +113,19 @@ ChannelEndPoint::setSpec(const char *hostName, long port) {
 bool
 ChannelEndPoint::getSpec(char **socketUri) const {
 
-  if (socketUri) *socketUri = NULL;
+  if (socketUri)
+  {
+    *socketUri = NULL;
+  }
+  else
+  {
+    return false;
+  }
 
   char *unixPath = NULL;
   char *hostName = NULL;
   long port = -1;
 
-  char *newSocketUri = NULL;
   int length = -1;
 
   if (getUnixPath(&unixPath))
@@ -133,17 +139,21 @@ ChannelEndPoint::getSpec(char **socketUri) const {
 
   if (length > 0)
   {
-    newSocketUri = static_cast<char *>(calloc(length + 1, sizeof(char)));
-    if (isUnixSocket())
-      snprintf(newSocketUri, length+1, "unix:%s", unixPath);
-    else
-      snprintf(newSocketUri, length+1, "tcp:%s:%ld", hostName, port);
+    char *newSocketUri = static_cast<char *>(calloc(length + 1, sizeof(char)));
+
+    if (newSocketUri)
+    {
+      if (isUnixSocket())
+        snprintf(newSocketUri, length+1, "unix:%s", unixPath);
+      else
+        snprintf(newSocketUri, length+1, "tcp:%s:%ld", hostName, port);
 
-    if (socketUri)
       *socketUri = strdup(newSocketUri);
+
+      SAFE_FREE(newSocketUri);
+    }
   }
 
-  SAFE_FREE(newSocketUri);
   SAFE_FREE(unixPath);
   SAFE_FREE(hostName);
 
diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp
index 5b6c2b4..fa8ba9a 100644
--- a/nxcomp/src/Loop.cpp
+++ b/nxcomp/src/Loop.cpp
@@ -6222,6 +6222,8 @@ int WaitForRemote(ChannelEndPoint &socketAddress)
 
   pFD = ListenConnection(socketAddress, "NX");
 
+  SAFE_FREE(socketUri);
+
   socketAddress.getSpec(&socketUri);
   nxinfo << "Loop: Waiting for connection from "
          << hostLabel  << " on socket '" << socketUri

--
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