summaryrefslogtreecommitdiffstats
path: root/generic/tclListObj.c
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-08-13 11:56:12 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-08-13 11:56:12 (GMT)
commite2d5a2cd606bb2952ffe3c2f00fdcc0132b57130 (patch)
tree39da0c77e31060d81deb9f63f75cc5e0309855dd /generic/tclListObj.c
parent5860a8926709c0d0c4fad457796af2b666a39ca1 (diff)
downloadtcl-e2d5a2cd606bb2952ffe3c2f00fdcc0132b57130.zip
tcl-e2d5a2cd606bb2952ffe3c2f00fdcc0132b57130.tar.gz
tcl-e2d5a2cd606bb2952ffe3c2f00fdcc0132b57130.tar.bz2
Merge in fix for end+1 indices.
Diffstat (limited to 'generic/tclListObj.c')
-rw-r--r--generic/tclListObj.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index dac75d4..fd69c96 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -2927,6 +2927,14 @@ TclLsetFlat(
}
indexArray++;
+ /*
+ * Special case 0-length lists. The Tcl indexing function treat
+ * will return any value beyond length as TCL_SIZE_MAX for this
+ * case.
+ */
+ if ((index == TCL_SIZE_MAX) && (elemCount == 0)) {
+ index = 0;
+ }
if (index < 0 || index > elemCount
|| (valueObj == NULL && index >= elemCount)) {
/* ...the index points outside the sublist. */