diff options
author | dgp <dgp@users.sourceforge.net> | 2011-04-21 17:32:20 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2011-04-21 17:32:20 (GMT) |
commit | d3a0ad0b83779f8b3ad8b665c8a64461dfc56b33 (patch) | |
tree | ff599a870d9438f3b28c983d0ac8121bea25f65b /generic/tclCmdIL.c | |
parent | 7522eeff966d066c292c39a89986a78922d65f73 (diff) | |
parent | fb1e4a18589dcd6dcf8bab488503e3ce89873098 (diff) | |
download | tcl-d3a0ad0b83779f8b3ad8b665c8a64461dfc56b33.zip tcl-d3a0ad0b83779f8b3ad8b665c8a64461dfc56b33.tar.gz tcl-d3a0ad0b83779f8b3ad8b665c8a64461dfc56b33.tar.bz2 |
Limits on list length were too strict. Revised panics to errors where possible.
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r-- | generic/tclCmdIL.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index b6e9f21..64348ad 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -2579,24 +2579,15 @@ Tcl_LrepeatObjCmd( objc -= 2; objv += 2; - /* - * Final sanity check. Total number of elements must fit in a signed - * integer. We also limit the number of elements to 512M-1 so allocations - * on 32-bit machines are guaranteed to be less than 2GB! [Bug 2130992] - */ + /* Final sanity check. Do not exceed limits on max list length. */ - totalElems = objc * elementCount; - if (totalElems != 0 && (totalElems/objc != elementCount - || totalElems/elementCount != objc)) { - Tcl_AppendResult(interp, "too many elements in result list", NULL); - Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); - return TCL_ERROR; - } - if (totalElems >= 0x20000000) { - Tcl_AppendResult(interp, "too many elements in result list", NULL); + if (elementCount && objc > LIST_MAX/elementCount) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "max length of a Tcl list (%d elements) exceeded", LIST_MAX)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); return TCL_ERROR; } + totalElems = objc * elementCount; /* * Get an empty list object that is allocated large enough to hold each |