Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bug 667527 - Remove the array-length limitation from the method used …

…in certain cases to append values to newborn arrays. r=dmandelin, a=johnath
  • Loading branch information...
commit a7e679b59ee841c8cb5c81b505b0405c76d7fcd1 1 parent 52793df
jswalden jswalden authored
6 js/src/jsarray.cpp
@@ -2119,12 +2119,6 @@ ArrayCompPushImpl(JSContext *cx, JSObject *obj, const Value &v)
2119 2119 JS_ASSERT(length <= obj->getDenseArrayCapacity());
2120 2120
2121 2121 if (length == obj->getDenseArrayCapacity()) {
2122   - if (length > JS_ARGS_LENGTH_MAX) {
2123   - JS_ReportErrorNumberUC(cx, js_GetErrorMessage, NULL,
2124   - JSMSG_ARRAY_INIT_TOO_BIG);
2125   - return false;
2126   - }
2127   -
2128 2122 /*
2129 2123 * An array comprehension cannot add holes to the array. So we can use
2130 2124 * ensureSlots instead of ensureDenseArrayElements.
1  js/src/tests/ecma_5/JSON/jstests.list
@@ -3,6 +3,7 @@ script cyclic-stringify.js
3 3 script small-codepoints.js
4 4 script parse.js
5 5 script parse-crockford-01.js
  6 +script parse-mega-huge-array.js
6 7 script parse-primitives.js
7 8 script parse-reviver.js
8 9 script parse-syntax-errors-01.js
28 js/src/tests/ecma_5/JSON/parse-mega-huge-array.js
... ... @@ -0,0 +1,28 @@
  1 +// Any copyright is dedicated to the Public Domain.
  2 +// http://creativecommons.org/licenses/publicdomain/
  3 +
  4 +var gTestfile = 'parse-mega-huge-array.js';
  5 +//-----------------------------------------------------------------------------
  6 +var BUGNUMBER = 667527;
  7 +var summary = "JSON.parse should parse arrays of essentially unlimited size";
  8 +
  9 +print(BUGNUMBER + ": " + summary);
  10 +
  11 +/**************
  12 + * BEGIN TEST *
  13 + **************/
  14 +
  15 +var str = '[';
  16 +for (var i = 0, sz = Math.pow(2, 21); i < sz; i++)
  17 + str += '0,';
  18 +str += '0]';
  19 +
  20 +var arr = JSON.parse(str);
  21 +assertEq(arr.length, Math.pow(2, 21) + 1);
  22 +
  23 +/******************************************************************************/
  24 +
  25 +if (typeof reportCompare === "function")
  26 + reportCompare(true, true);
  27 +
  28 +print("Tests complete");
1  js/src/tests/js1_8_5/regress/jstests.list
... ... @@ -1,4 +1,5 @@
1 1 url-prefix ../../jsreftest.html?test=js1_8_5/regress/
  2 +script no-array-comprehension-length-limit.js
2 3 script regress-500528.js
3 4 script regress-533876.js
4 5 script regress-541255-0.js
14 js/src/tests/js1_8_5/regress/no-array-comprehension-length-limit.js
... ... @@ -0,0 +1,14 @@
  1 +/*
  2 + * Any copyright is dedicated to the Public Domain.
  3 + * http://creativecommons.org/licenses/publicdomain/
  4 + */
  5 +function range(n)
  6 +{
  7 + var i = 0;
  8 + while (i < n)
  9 + yield i++;
  10 +}
  11 +
  12 +[0 for (_ in range(Math.pow(2, 20)))];
  13 +
  14 +reportCompare(true, true);

0 comments on commit a7e679b

Please sign in to comment.
Something went wrong with that request. Please try again.