summaryrefslogtreecommitdiffstats
path: root/generic/tclTest.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclTest.c')
-rw-r--r--generic/tclTest.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 03b5717..aaadc1d 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -6819,12 +6819,18 @@ TestNumUtfCharsCmd(
Tcl_Obj *const objv[])
{
if (objc > 1) {
- int len = -1;
+ int numBytes, len, limit = -1;
+ const char *bytes = Tcl_GetStringFromObj(objv[1], &numBytes);
if (objc > 2) {
- (void) Tcl_GetIntFromObj(interp, objv[2], &len);
+ if (TclGetIntForIndex(interp, objv[2], numBytes, &limit) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (limit > numBytes + 1) {
+ limit = numBytes + 1;
+ }
}
- len = Tcl_NumUtfChars(Tcl_GetString(objv[1]), len);
+ len = Tcl_NumUtfChars(bytes, limit);
Tcl_SetObjResult(interp, Tcl_NewIntObj(len));
}
return TCL_OK;