Bug 708819 - Avoid recursion through Error.prototype.toString/toSource r=luke

--HG--
extra : rebase_source : 7e6437b497886bbd8109a6c8a392923fff537c84
This commit is contained in:
Tom Schuster 2011-12-19 14:17:00 +01:00
parent 46fa50e1b0
commit 1f4f431168
2 changed files with 14 additions and 0 deletions

View File

@ -0,0 +1,12 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
try {
var e = new Error();
e.name = e;
"" + e;
} catch (e) {
assertEq(e.message, 'too much recursion');
}

View File

@ -803,6 +803,7 @@ Exception(JSContext *cx, uintN argc, Value *vp)
static JSBool
exn_toString(JSContext *cx, uintN argc, Value *vp)
{
JS_CHECK_RECURSION(cx, return false);
CallArgs args = CallArgsFromVp(argc, vp);
/* Step 2. */
@ -881,6 +882,7 @@ exn_toString(JSContext *cx, uintN argc, Value *vp)
static JSBool
exn_toSource(JSContext *cx, uintN argc, Value *vp)
{
JS_CHECK_RECURSION(cx, return false);
CallArgs args = CallArgsFromVp(argc, vp);
JSObject *obj = ToObject(cx, &args.thisv());