diff options
| author | dgp@users.sourceforge.net <dgp> | 2011-04-21 17:32:20 (GMT) |
|---|---|---|
| committer | dgp@users.sourceforge.net <dgp> | 2011-04-21 17:32:20 (GMT) |
| commit | 393774cf3032c1fb96401918defb994080db3be8 (patch) | |
| tree | ff599a870d9438f3b28c983d0ac8121bea25f65b /generic/tclCmdIL.c | |
| parent | 19572419d3922118dad03e33289549dc1e38bcec (diff) | |
| parent | c11c9497411ee623fa3977b4a1f0d723cd4f629c (diff) | |
| download | tcl-393774cf3032c1fb96401918defb994080db3be8.zip tcl-393774cf3032c1fb96401918defb994080db3be8.tar.gz tcl-393774cf3032c1fb96401918defb994080db3be8.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 |
