Bug 800878 - EvalInFrame, Check debug mode before iterating the stack. r=luke,decoder
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Wed, 17 Oct 2012 14:37:09 -0700
changeset 110743 20c4309100e148edc38bf69ce45631c225a439c8
parent 110738 f7cb509ab5b063e1293fea5730ed7682e70347cf
child 110744 0f76c881a47b65a5fcd349d41652a319b3382fe7
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersluke, decoder
bugs800878
milestone19.0a1
Bug 800878 - EvalInFrame, Check debug mode before iterating the stack. r=luke,decoder
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2518,16 +2518,23 @@ EvalInFrame(JSContext *cx, unsigned argc
     JSString *str = JSVAL_TO_STRING(argv[1]);
 
     bool saveCurrent = (argc >= 3 && JSVAL_IS_BOOLEAN(argv[2]))
                         ? !!(JSVAL_TO_BOOLEAN(argv[2]))
                         : false;
 
     JS_ASSERT(cx->hasfp());
 
+    /* This is a copy of CheckDebugMode. */
+    if (!JS_GetDebugMode(cx)) {
+        JS_ReportErrorFlagsAndNumber(cx, JSREPORT_ERROR, js_GetErrorMessage,
+                                     NULL, JSMSG_NEED_DEBUG_MODE);
+        return false;
+    }
+
     /* Debug-mode currently disables Ion compilation. */
     ScriptFrameIter fi(cx);
     for (uint32_t i = 0; i < upCount; ++i, ++fi) {
         if (!fi.interpFrame()->prev())
             break;
     }
 
     bool saved = false;