From 772d2da10b02fc06220a92d5f9d4f33b752a9553 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Sun, 22 Jul 2018 20:44:16 +0000 Subject: Fix for [ba921a8d98e02a96] - concatenating binary array with empty string yields the empty string. --- generic/tclStringObj.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 3bb6112..2cda2c4 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -3065,24 +3065,22 @@ TclStringCat( * Result will be pure byte array. Pre-size it */ + int numBytes; ov = objv; oc = objc; do { Tcl_Obj *objPtr = *ov++; - if (objPtr->bytes == NULL) { - int numBytes; + Tcl_GetByteArrayFromObj(objPtr, &numBytes); /* PANIC? */ - Tcl_GetByteArrayFromObj(objPtr, &numBytes); /* PANIC? */ - if (numBytes) { - last = objc - oc; - if (length == 0) { - first = last; - } else if (numBytes > INT_MAX - length) { - goto overflow; - } - length += numBytes; + if (numBytes) { + last = objc - oc; + if (length == 0) { + first = last; + } else if (numBytes > INT_MAX - length) { + goto overflow; } + length += numBytes; } } while (--oc); } else if (allowUniChar && requestUniChar) { -- cgit v0.12