mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-08 12:22:34 +00:00
Bug 635389 - Check for overrecursion in functions that might need it. r=jorendorff
--HG-- extra : rebase_source : 72d6f2c915a4aa19e9820ea4f66039f75421c32d
This commit is contained in:
parent
63ee7fd726
commit
2ff8950407
@ -1312,8 +1312,6 @@ static JSBool
|
||||
array_toString_sub(JSContext *cx, JSObject *obj, JSBool locale,
|
||||
JSString *sepstr, Value *rval)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
|
||||
static const jschar comma = ',';
|
||||
const jschar *sep;
|
||||
size_t seplen;
|
||||
@ -1395,6 +1393,8 @@ array_toString_sub(JSContext *cx, JSObject *obj, JSBool locale,
|
||||
static JSBool
|
||||
array_toString(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
|
||||
JSObject *obj = ToObject(cx, &vp[1]);
|
||||
if (!obj)
|
||||
return false;
|
||||
@ -1429,6 +1429,8 @@ array_toString(JSContext *cx, uintN argc, Value *vp)
|
||||
static JSBool
|
||||
array_toLocaleString(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
|
||||
JSObject *obj = ToObject(cx, &vp[1]);
|
||||
if (!obj)
|
||||
return false;
|
||||
@ -1526,6 +1528,8 @@ InitArrayObject(JSContext *cx, JSObject *obj, jsuint length, const Value *vector
|
||||
static JSBool
|
||||
array_join(JSContext *cx, uintN argc, Value *vp)
|
||||
{
|
||||
JS_CHECK_RECURSION(cx, return false);
|
||||
|
||||
JSString *str;
|
||||
if (argc == 0 || vp[2].isUndefined()) {
|
||||
str = NULL;
|
||||
|
46
js/src/tests/ecma_5/extensions/array-toString-recursion.js
Normal file
46
js/src/tests/ecma_5/extensions/array-toString-recursion.js
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/licenses/publicdomain/
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var BUGNUMBER = 635389;
|
||||
var summary = 'Infinite recursion via [].{toString,toLocaleString,join}';
|
||||
|
||||
print(BUGNUMBER + ": " + summary);
|
||||
|
||||
/**************
|
||||
* BEGIN TEST *
|
||||
**************/
|
||||
|
||||
try
|
||||
{
|
||||
var x = [];
|
||||
x.join = Array.prototype.toString;
|
||||
"" + x;
|
||||
throw new Error("should have thrown");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
assertEq(e instanceof InternalError, true,
|
||||
"should have thrown for over-recursion");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var x = { toString: Array.prototype.toString, join: Array.prototype.toString };
|
||||
"" + x;
|
||||
throw new Error("should have thrown");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
assertEq(e instanceof InternalError, true,
|
||||
"should have thrown for over-recursion");
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
||||
print("All tests passed!");
|
@ -9,6 +9,7 @@ script bug352085.js
|
||||
script bug472534.js
|
||||
script bug496985.js
|
||||
script bug566661.js
|
||||
script array-toString-recursion.js
|
||||
skip-if(!xulRuntime.shell) script cross-global-eval-is-indirect.js # needs newGlobal()
|
||||
script eval-native-callback-is-indirect.js
|
||||
script extension-methods-reject-null-undefined-this.js
|
||||
|
Loading…
Reference in New Issue
Block a user