diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-07-07 13:03:38 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-07-07 13:03:38 (GMT) |
commit | 6b55b10a00d68be898d259e1b0331f8235d805e9 (patch) | |
tree | 0dd71f5e69102cf9abbd71a914991203ea7a0a4c /generic/tclCmdIL.c | |
parent | 1d4256a37e4dd01fbd76f44bb9f9a28603e903ef (diff) | |
download | tcl-6b55b10a00d68be898d259e1b0331f8235d805e9.zip tcl-6b55b10a00d68be898d259e1b0331f8235d805e9.tar.gz tcl-6b55b10a00d68be898d259e1b0331f8235d805e9.tar.bz2 |
Eliminate totalElems (left-over from 'lrepeat'). Bug in checking LIST_MAX (also originally taken from 'lrepeat')
Diffstat (limited to 'generic/tclCmdIL.c')
-rw-r--r-- | generic/tclCmdIL.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 05b20d4..c28c283 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -4492,7 +4492,7 @@ Tcl_RangeObjCmd( Tcl_Obj *const objv[]) /* The argument objects. */ { - Tcl_WideInt elementCount, i, totalElems; + Tcl_WideInt elementCount, i; Tcl_Obj *const *argPtr; Tcl_WideInt start, end, step;//, count; Tcl_Obj *listPtr, **dataArray = NULL; @@ -4708,22 +4708,21 @@ Tcl_RangeObjCmd( /* Final sanity check. Do not exceed limits on max list length. */ - if (elementCount && objc > LIST_MAX/elementCount) { + if (elementCount > LIST_MAX) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "max length of a Tcl list (%" TCL_Z_MODIFIER "u elements) exceeded", (size_t)LIST_MAX)); Tcl_SetErrorCode(interp, "TCL", "MEMORY", NULL); status = TCL_ERROR; goto done; } - totalElems = elementCount; /* * Get an empty list object that is allocated large enough to hold each * init value elementCount times. */ - listPtr = Tcl_NewListObj(totalElems, NULL); - if (totalElems) { + listPtr = Tcl_NewListObj(elementCount, NULL); + if (elementCount) { List *listRepPtr = ListRepPtr(listPtr); listRepPtr->elemCount = elementCount; @@ -4734,7 +4733,7 @@ Tcl_RangeObjCmd( * Set the elements. */ - CLANG_ASSERT(dataArray || totalElems == 0 ); + CLANG_ASSERT(dataArray || elementCount == 0 ); if (!really) { int k = 0; |