diff options
author | Mihai Moldovan <ionic@ionic.de> | 2017-12-30 03:31:20 +0100 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2017-12-30 03:31:20 +0100 |
commit | e13e31f752c0b204f964ee1df272a6b31ce51189 (patch) | |
tree | d3bc2368895d03487b994fedff953ac457c4acc0 /nxcomp/src/ChannelEndPoint.cpp | |
parent | 2d44051aad601e074790eaf482ef09090131ca5d (diff) | |
parent | 367bec59524ffc3d005ae8908c5edf42e9b01ca7 (diff) | |
download | nx-libs-e13e31f752c0b204f964ee1df272a6b31ce51189.tar.gz nx-libs-e13e31f752c0b204f964ee1df272a6b31ce51189.tar.bz2 nx-libs-e13e31f752c0b204f964ee1df272a6b31ce51189.zip |
Merge branch 'uli42-pr/fix_abstract' into 3.6.x
Attributes GH PR #615: https://github.com/ArcticaProject/nx-libs/pull/615
Fixes: ArcticaProject/nx-libs#612
Fixes: ArcticaProject/nx-libs#572
Diffstat (limited to 'nxcomp/src/ChannelEndPoint.cpp')
-rw-r--r-- | nxcomp/src/ChannelEndPoint.cpp | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/nxcomp/src/ChannelEndPoint.cpp b/nxcomp/src/ChannelEndPoint.cpp index a1d96086a..7768df137 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); @@ -170,8 +180,6 @@ ChannelEndPoint::setDefaultUnixPath(char *path) { if (path && strlen(path)) defaultUnixPath_ = strdup(path); - else - defaultUnixPath_ = NULL; isUnix_ = getUnixPath(); } @@ -199,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; @@ -219,8 +230,7 @@ ChannelEndPoint::getUnixPath(char **unixPath) const { return false; } - if (unixPath) - *unixPath = strdup(path); + *unixPath = strdup(path); return true; } @@ -263,8 +273,10 @@ ChannelEndPoint::getTCPHostAndPort(char **host, long *port) const { char *h = NULL; ssize_t h_len; - if (host) *host = NULL; - if (port) *port = 0; + if (host) + *host = NULL; + if (port) + *port = 0; if (getPort(&p)) { h_len = 0; |