diff options
author | dgp <dgp@users.sourceforge.net> | 2015-11-20 16:59:55 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2015-11-20 16:59:55 (GMT) |
commit | a166c55da0595a28b635191dbb6307cbb85428d4 (patch) | |
tree | 920bfb5bca1221572d6f4a11a7a2c1732df367c9 /generic | |
parent | 94b81dda496d4ab92cd28c9fa1778dec5b2e8d67 (diff) | |
parent | 7e6cdc9cc44c2cbf916639ff537171bd10c175dd (diff) | |
download | tcl-a166c55da0595a28b635191dbb6307cbb85428d4.zip tcl-a166c55da0595a28b635191dbb6307cbb85428d4.tar.gz tcl-a166c55da0595a28b635191dbb6307cbb85428d4.tar.bz2 |
Tcl_ListObjReplace() early out when > LIST_MAX attempted.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclListObj.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c index fa67ee6..0dfa845 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -906,8 +906,13 @@ Tcl_ListObjReplace( count = numElems - first; } + if (objc > LIST_MAX - (numElems - count)) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "max length of a Tcl list (%d elements) exceeded", LIST_MAX)); + return TCL_ERROR; + } isShared = (listRepPtr->refCount > 1); - numRequired = numElems - count + objc; + numRequired = numElems - count + objc; /* Known <= LIST_MAX */ for (i = 0; i < objc; i++) { Tcl_IncrRefCount(objv[i]); |