summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdIL.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2011-04-21 17:32:20 (GMT)
committerdgp <dgp@users.sourceforge.net>2011-04-21 17:32:20 (GMT)
commitb9fb710078ba75c6ff78aa0956f35b8210ed1545 (patch)
treeff599a870d9438f3b28c983d0ac8121bea25f65b /generic/tclCmdIL.c
parent6998aa298515d30c3b2e0cee78e2af476fd2ed91 (diff)
parent8850f2128d8e89bd89e49b15414166f25de25c0b (diff)
downloadtcl-b9fb710078ba75c6ff78aa0956f35b8210ed1545.zip
tcl-b9fb710078ba75c6ff78aa0956f35b8210ed1545.tar.gz
tcl-b9fb710078ba75c6ff78aa0956f35b8210ed1545.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.c19
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