diff --git a/js/src/jit-test/tests/basic/bug708819.js b/js/src/jit-test/tests/basic/bug708819.js new file mode 100644 index 00000000000..8f3f0a552e0 --- /dev/null +++ b/js/src/jit-test/tests/basic/bug708819.js @@ -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'); +} diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index bfec00429ce..091d9d4d175 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -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());