summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-05-19 11:00:04 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-05-19 11:00:04 (GMT)
commitb4b177bc926f1e246054462ba147e0448a0a95e3 (patch)
tree683daa1e2e627a09aad80ed74f28dc0e54a00218 /generic/tclStringObj.c
parent2e04ff831d043373741c9252f3ff791bbc2bbda9 (diff)
downloadtcl-b4b177bc926f1e246054462ba147e0448a0a95e3.zip
tcl-b4b177bc926f1e246054462ba147e0448a0a95e3.tar.gz
tcl-b4b177bc926f1e246054462ba147e0448a0a95e3.tar.bz2
Elaborate TIP #481 implementation: Make clear that Tcl_GetUnicodeFromObj and Tcl_GetStringFromObj panic if lengthPtr points to an int and length > INT_MAX.
Also if sizeof(int) == sizeof(size_t), prefer the size_t variant of the functions
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index a3ee1c3..d0bac17 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -686,6 +686,10 @@ TclGetUnicodeFromObj(
}
if (lengthPtr != NULL) {
+ if (stringPtr->numChars > INT_MAX) {
+ Tcl_Panic("Tcl_GetUnicodeFromObj with 'int' lengthPtr"
+ "cannot handle such long strings. Please use 'size_t'");
+ }
*lengthPtr = (int)stringPtr->numChars;
}
return stringPtr->unicode;