diff options
| -rw-r--r-- | generic/tclCmdIL.c | 5 | ||||
| -rw-r--r-- | tests/join.test | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index b41d312..77b8434 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -2160,7 +2160,7 @@ Tcl_JoinObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* The argument objects. */ { - int listLen; + int length, listLen; Tcl_Obj *resObjPtr = NULL, *joinObjPtr, **elemPtrs; if ((objc < 2) || (objc > 3)) { @@ -2191,7 +2191,8 @@ Tcl_JoinObjCmd( joinObjPtr = (objc == 2) ? Tcl_NewStringObj(" ", 1) : objv[2]; Tcl_IncrRefCount(joinObjPtr); - if (Tcl_GetCharLength(joinObjPtr) == 0) { + (void) Tcl_GetStringFromObj(joinObjPtr, &length); + if (length == 0) { TclStringCatObjv(interp, /* inPlace */ 0, listLen, elemPtrs, &resObjPtr); } else { diff --git a/tests/join.test b/tests/join.test index 4abe233..4aeb093 100644 --- a/tests/join.test +++ b/tests/join.test @@ -45,6 +45,11 @@ test join-3.1 {joinString is binary ok} { test join-3.2 {join is binary ok} { string length [join "a\0b a\0b a\0b"] } 11 + +test join-4.1 {shimmer segfault prevention} { + set l {0 0} + join $l $l +} {00 00} # cleanup ::tcltest::cleanupTests |
