summaryrefslogtreecommitdiffstats
path: root/generic/tclListObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-05 15:31:31 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-10-05 15:31:31 (GMT)
commit4721ffe64fe11287997ec892d58c375a73e3876d (patch)
tree5f79dc5d30c93701b4aca6678ca2ad9a84667119 /generic/tclListObj.c
parent5ceec60eb3a7b5b60b1cab78704903717ff98863 (diff)
downloadtcl-4721ffe64fe11287997ec892d58c375a73e3876d.zip
tcl-4721ffe64fe11287997ec892d58c375a73e3876d.tar.gz
tcl-4721ffe64fe11287997ec892d58c375a73e3876d.tar.bz2
Fix [1599352cca] and related issues
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r--generic/tclListObj.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 88a332f..a994fd7 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -1945,7 +1945,8 @@ UpdateStringOfList(
char localFlags[LOCAL_SIZE], *flagPtr = NULL;
List *listRepPtr = ListRepPtr(listPtr);
int numElems = listRepPtr->elemCount;
- int i, length, bytesNeeded = 0;
+ int i, length;
+ unsigned int bytesNeeded = 0;
const char *elem;
char *dst;
Tcl_Obj **elemPtrs;
@@ -1986,11 +1987,11 @@ UpdateStringOfList(
flagPtr[i] = (i ? TCL_DONT_QUOTE_HASH : 0);
elem = TclGetStringFromObj(elemPtrs[i], &length);
bytesNeeded += TclScanElement(elem, length, flagPtr+i);
- if (bytesNeeded < 0) {
+ if (bytesNeeded > INT_MAX) {
Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
}
}
- if (bytesNeeded > INT_MAX - numElems + 1) {
+ if (bytesNeeded + numElems > INT_MAX + 1U) {
Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
}
bytesNeeded += numElems;