aboutsummaryrefslogtreecommitdiff
path: root/nxcomp/src/ChannelEndPoint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'nxcomp/src/ChannelEndPoint.cpp')
-rw-r--r--nxcomp/src/ChannelEndPoint.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/nxcomp/src/ChannelEndPoint.cpp b/nxcomp/src/ChannelEndPoint.cpp
index a1d96086a..2abc0ee6a 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);