diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-01-17 10:35:18 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-01-17 10:35:18 (GMT) |
commit | e5a2ebd71b2aa2b31ca5128eb47ae0a7fdd20bd5 (patch) | |
tree | 67c205a4448d7fb5212f23d7982bc44da6a3ce2d /generic/tclStringObj.c | |
parent | a9eaf6765198716158f4927d71f64d20182f1ad2 (diff) | |
download | tcl-e5a2ebd71b2aa2b31ca5128eb47ae0a7fdd20bd5.zip tcl-e5a2ebd71b2aa2b31ca5128eb47ae0a7fdd20bd5.tar.gz tcl-e5a2ebd71b2aa2b31ca5128eb47ae0a7fdd20bd5.tar.bz2 |
Follow-up to [767e070d35]: Tcl_GetRange and Tcl_GetUniChar do not validate index inputs.
Now that Tcl_GetRange() checks its arguments, the callers of this function don't have to do that any more.
This also shows a off-by-one error in the Tcl_GetRange() check
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r-- | generic/tclStringObj.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index edfcb9f..fc675cf 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -739,8 +739,7 @@ Tcl_GetUnicodeFromObj( * * Create a Tcl Object that contains the chars between first and last of * the object indicated by "objPtr". If the object is not already a - * String object, convert it to one. The first and last indices are - * assumed to be in the appropriate range. + * String object, convert it to one. * * Results: * Returns a new Tcl Object of the String type. @@ -818,8 +817,8 @@ Tcl_GetRange( FillUnicodeRep(objPtr); stringPtr = GET_STRING(objPtr); } - if (last > stringPtr->numChars) { - last = stringPtr->numChars; + if (last >= stringPtr->numChars) { + last = stringPtr->numChars - 1; } if (last < first) { return Tcl_NewObj(); |