summaryrefslogtreecommitdiffstats
path: root/generic/tclUtf.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-12 21:17:05 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-12 21:17:05 (GMT)
commit99c0854650e170e35db77c4984ab41fb6b398f26 (patch)
tree2ea75748a3a6a9df6c3059fae3a05e2d9a073e23 /generic/tclUtf.c
parentdd3240d86038ac4267439eb5535a17293f125b12 (diff)
downloadtcl-99c0854650e170e35db77c4984ab41fb6b398f26.zip
tcl-99c0854650e170e35db77c4984ab41fb6b398f26.tar.gz
tcl-99c0854650e170e35db77c4984ab41fb6b398f26.tar.bz2
Little tweak to Tcl_UniCharAtIndex(): Protect against negative index, return -1 in that case.
Diffstat (limited to 'generic/tclUtf.c')
-rw-r--r--generic/tclUtf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 281753c..309a344 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -1145,6 +1145,9 @@ Tcl_UniCharAtIndex(
Tcl_UniChar ch = 0;
int i = 0;
+ if (index < 0) {
+ return -1;
+ }
while (index-- > 0) {
i = TclUtfToUniChar(src, &ch);
src += i;