diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-12 21:17:05 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-05-12 21:17:05 (GMT) |
commit | 99c0854650e170e35db77c4984ab41fb6b398f26 (patch) | |
tree | 2ea75748a3a6a9df6c3059fae3a05e2d9a073e23 /generic/tclUtf.c | |
parent | dd3240d86038ac4267439eb5535a17293f125b12 (diff) | |
download | tcl-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.c | 3 |
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; |