diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-11-17 19:47:08 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-11-17 19:47:08 (GMT) |
commit | afff904993ae1dae22777a15c96b97f53ac989c4 (patch) | |
tree | 61caf84b6ba511160614cef3bf76deef1f30c58c /unix/tclUnixSock.c | |
parent | 1f6c360968fab22aa02a30a72c196a8f8eb19c0c (diff) | |
parent | fc5da6d413b6981ebe7235f63d505f3290cc6c5c (diff) | |
download | tcl-afff904993ae1dae22777a15c96b97f53ac989c4.zip tcl-afff904993ae1dae22777a15c96b97f53ac989c4.tar.gz tcl-afff904993ae1dae22777a15c96b97f53ac989c4.tar.bz2 |
Merge 8.7
Diffstat (limited to 'unix/tclUnixSock.c')
-rw-r--r-- | unix/tclUnixSock.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index ae6c717..b0c0808 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.c @@ -241,7 +241,7 @@ InitializeHostName( if (dot != NULL) { char *node = ckalloc(dot - u.nodename + 1); - memcpy(node, u.nodename, (size_t) (dot - u.nodename)); + memcpy(node, u.nodename, dot - u.nodename); node[dot - u.nodename] = '\0'; hp = TclpGetHostByName(node); ckfree(node); @@ -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'; + } } /* |