diff options
author | dgp <dgp@users.sourceforge.net> | 2018-11-09 16:16:17 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2018-11-09 16:16:17 (GMT) |
commit | f51d22b7c34b29e8adec4210fc57a86f5c6f87da (patch) | |
tree | 9b146c720c0c699f5c443e5001467bc4d3bb0a4a /generic/tclListObj.c | |
parent | 91fc51027134f52d557aefc4674a61718e5f5155 (diff) | |
parent | d594b7a08e5e0c42372c17f040fe2486ab63df78 (diff) | |
download | tcl-f51d22b7c34b29e8adec4210fc57a86f5c6f87da.zip tcl-f51d22b7c34b29e8adec4210fc57a86f5c6f87da.tar.gz tcl-f51d22b7c34b29e8adec4210fc57a86f5c6f87da.tar.bz2 |
Merge and adapt 8.6
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r-- | generic/tclListObj.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 319954c..b7f73ed 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -2132,7 +2132,7 @@ UpdateStringOfList( # define LOCAL_SIZE 64 char localFlags[LOCAL_SIZE], *flagPtr = NULL; int numElems, i, length, bytesNeeded = 0; - const char *elem; + const char *elem, *start; char *dst; Tcl_Obj **elemPtrs; List *listRepPtr; @@ -2191,7 +2191,7 @@ UpdateStringOfList( * Pass 2: copy into string rep buffer. */ - dst = Tcl_InitStringRep(listPtr, NULL, bytesNeeded); + start = dst = Tcl_InitStringRep(listPtr, NULL, bytesNeeded); TclOOM(dst, bytesNeeded); for (i = 0; i < numElems; i++) { flagPtr[i] |= (i ? TCL_DONT_QUOTE_HASH : 0); @@ -2199,7 +2199,9 @@ UpdateStringOfList( dst += TclConvertElement(elem, length, dst, flagPtr[i]); *dst++ = ' '; } - (void) Tcl_InitStringRep(listPtr, NULL, bytesNeeded); + + /* Set the string length to what was actually written, the safe choice */ + (void) Tcl_InitStringRep(listPtr, NULL, dst - 1 - start); if (flagPtr != localFlags) { ckfree(flagPtr); |