Bug 797495 - Loosen overly tight assertion in Parser::setStrictMode(). r=luke.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 03 Oct 2012 23:29:24 -0700
changeset 109322 5215c9e775538a2e9232d8e981c07b7c968608d7
parent 109321 0575f1f6062ec513cb1a89f322b4914414771476
child 109323 6cb9dded5fed50f0e2856402fc42f56fb09bfe6e
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersluke
bugs797495
milestone18.0a1
Bug 797495 - Loosen overly tight assertion in Parser::setStrictMode(). r=luke.
js/src/frontend/Parser.cpp
js/src/jit-test/tests/basic/bug797495.js
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -1765,17 +1765,17 @@ Parser::functionExpr()
  */
 bool
 Parser::setStrictMode(bool strictMode)
 {
     if (pc->sc->strictModeState != StrictMode::UNKNOWN) {
         // Strict mode was inherited.
         JS_ASSERT(pc->sc->strictModeState == StrictMode::STRICT);
         if (pc->sc->isFunction) {
-            JS_ASSERT(pc->parent->sc->strictModeState == StrictMode::STRICT);
+            JS_ASSERT_IF(pc->parent, pc->parent->sc->strictModeState == StrictMode::STRICT);
         } else {
             JS_ASSERT_IF(pc->staticLevel == 0,
                          StrictModeFromContext(context) == StrictMode::STRICT);
         }
         return true;
     }
 
     if (strictMode) {
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug797495.js
@@ -0,0 +1,6 @@
+try {
+  // Don't assert.
+  options("strict_mode");
+  var f = Function("for(w in\\");
+} catch (e) {
+}