diff options
author | dgp <dgp@users.sourceforge.net> | 2011-04-21 16:53:44 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2011-04-21 16:53:44 (GMT) |
commit | fb1e4a18589dcd6dcf8bab488503e3ce89873098 (patch) | |
tree | 52c343f306e6cc25dc62d6895972cdf716e9c45b /generic/tclCmdIL.c | |
parent | 842312f3957922d5d3255fd5d2a511220f26c748 (diff) | |
download | tcl-fb1e4a18589dcd6dcf8bab488503e3ce89873098.zip tcl-fb1e4a18589dcd6dcf8bab488503e3ce89873098.tar.gz tcl-fb1e4a18589dcd6dcf8bab488503e3ce89873098.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 | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 25fd078..13db6d5 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -2429,21 +2429,14 @@ 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/objc != elementCount || totalElems/elementCount != objc) { - Tcl_AppendResult(interp, "too many elements in result list", NULL); - return TCL_ERROR; - } - if (totalElems >= 0x20000000) { - Tcl_AppendResult(interp, "too many elements in result list", NULL); + if (objc > LIST_MAX/elementCount) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "max length of a Tcl list (%d elements) exceeded", LIST_MAX)); return TCL_ERROR; } + totalElems = objc * elementCount; /* * Get an empty list object that is allocated large enough to hold each |