summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2018-11-06 09:51:55 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2018-11-06 09:51:55 (GMT)
commit2798a075ee62ea5ab4aa80279d614a8634ba378a (patch)
tree0a09cb9e38547d3b35e396717c0b04302eb5bd8a /unix
parent5429d6aeaf940119a7a7bb0a3d54ae966c234314 (diff)
parentf7dfeb706fb75bccd0aae6cd6119fccdfb6bd8d0 (diff)
downloadtcl-2798a075ee62ea5ab4aa80279d614a8634ba378a.zip
tcl-2798a075ee62ea5ab4aa80279d614a8634ba378a.tar.gz
tcl-2798a075ee62ea5ab4aa80279d614a8634ba378a.tar.bz2
Implement TIP 445
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixSock.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c
index 2793d3b..bd54a2e 100644
--- a/unix/tclUnixSock.c
+++ b/unix/tclUnixSock.c
@@ -253,9 +253,6 @@ InitializeHostName(
native = u.nodename;
}
}
- if (native == NULL) {
- native = &tclEmptyString;
- }
#else /* !NO_UNAME */
/*
* Uname doesn't exist; try gethostname instead.
@@ -284,9 +281,15 @@ InitializeHostName(
#endif /* NO_UNAME */
*encodingPtr = Tcl_GetEncoding(NULL, NULL);
- *lengthPtr = strlen(native);
- *valuePtr = ckalloc(*lengthPtr + 1);
- memcpy(*valuePtr, native, *lengthPtr + 1);
+ if (native) {
+ *lengthPtr = strlen(native);
+ *valuePtr = ckalloc(*lengthPtr + 1);
+ memcpy(*valuePtr, native, *lengthPtr + 1);
+ } else {
+ *lengthPtr = 0;
+ *valuePtr = ckalloc(1);
+ *valuePtr[0] = '\0';
+ }
}
/*