diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-01-23 13:57:30 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-01-23 13:57:30 (GMT) |
commit | c58c25ef079a96e684e2be9bdf78040c84c3cf9b (patch) | |
tree | bb5613f01783a22bbf47ee9d2ab9974469c242a0 | |
parent | 21be09ba34563c7d9fd3b0d013fe643c63f00174 (diff) | |
download | tcl-c58c25ef079a96e684e2be9bdf78040c84c3cf9b.zip tcl-c58c25ef079a96e684e2be9bdf78040c84c3cf9b.tar.gz tcl-c58c25ef079a96e684e2be9bdf78040c84c3cf9b.tar.bz2 |
Protect Tcl_GetIndexFromObjStruct from invalid "offset" values, like 0 or -1. Undocumented, because I don't want to promote people start using that.
-rw-r--r-- | generic/tclIndexObj.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/generic/tclIndexObj.c b/generic/tclIndexObj.c index cc50fd3..0103cdb 100644 --- a/generic/tclIndexObj.c +++ b/generic/tclIndexObj.c @@ -144,7 +144,7 @@ Tcl_GetIndexFromObj(interp, objPtr, tablePtr, msg, flags, indexPtr) * returned and an error message is left in interp's result (unless * interp is NULL). The msg argument is used in the error * message; for example, if msg has the value "option" then the - * error message will say something flag 'bad option "foo": must be + * error message will say something like 'bad option "foo": must be * ...' * * Side effects: @@ -176,6 +176,10 @@ Tcl_GetIndexFromObjStruct(interp, objPtr, tablePtr, offset, msg, flags, Tcl_Obj *resultPtr; IndexRep *indexRep; + /* Protect against invalid values, like -1 or 0. */ + if (offset < (int)sizeof(char *)) { + offset = (int)sizeof(char *); + } /* * See if there is a valid cached result from a previous lookup. */ |