Bug 495166 - static-analysis error in jsparse.cpp JSCompiler::compileScript: return without going through label out. r=brendan.
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 28 May 2009 10:08:57 -0500
changeset 28817 26f38f9b8f493b1c381d6c89763a531a493f82cd
parent 28816 e7a08f46b514cd7fc74fe09107f94ae4e144f314
child 28818 ac3e487c5fffad1d1ef9f3353f3cadad297b1f66
child 28830 9a651521fd7107bc03488e51ad88c8a9121e4355
push id7273
push userrsayre@mozilla.com
push dateThu, 28 May 2009 22:52:43 +0000
treeherdermozilla-central@ac3e487c5fff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbrendan
bugs495166
milestone1.9.2a1pre
Bug 495166 - static-analysis error in jsparse.cpp JSCompiler::compileScript: return without going through label out. r=brendan.
js/src/jsparse.cpp
--- a/js/src/jsparse.cpp
+++ b/js/src/jsparse.cpp
@@ -810,67 +810,71 @@ JSCompiler::compileScript(JSContext *cx,
     JS_INIT_ARENA_POOL(&codePool, "code", 1024, sizeof(jsbytecode),
                        &cx->scriptStackQuota);
     JS_INIT_ARENA_POOL(&notePool, "note", 1024, sizeof(jssrcnote),
                        &cx->scriptStackQuota);
 
     JSCodeGenerator cg(&jsc, &codePool, &notePool, jsc.tokenStream.lineno);
 
     MUST_FLOW_THROUGH("out");
+
+    /* Null script early in case of error, to reduce our code footprint. */
+    script = NULL;
+
     cg.flags |= (uint16) tcflags;
     cg.scopeChain = scopeChain;
     if (!SetStaticLevel(&cg, TCF_GET_STATIC_LEVEL(tcflags)))
-        return NULL;
+        goto out;
 
     /*
      * If funbox is non-null after we create the new script, callerFrame->fun
      * was saved in the 0th object table entry.
      */
-    JSObjectBox *funbox = NULL;
+    JSObjectBox *funbox;
+    funbox = NULL;
 
     if (tcflags & TCF_COMPILE_N_GO) {
         if (source) {
             /*
              * Save eval program source in script->atomMap.vector[0] for the
              * eval cache (see obj_eval in jsobj.cpp).
              */
             JSAtom *atom = js_AtomizeString(cx, source, 0);
             if (!atom || !cg.atomList.add(&jsc, atom))
-                return NULL;
+                goto out;
         }
 
         if (callerFrame && callerFrame->fun) {
             /*
              * An eval script in a caller frame needs to have its enclosing
              * function captured in case it refers to an upvar, and someone
              * wishes to decompile it while it's running.
              */
             funbox = jsc.newObjectBox(FUN_OBJECT(callerFrame->fun));
             if (!funbox)
-                return NULL;
+                goto out;
             funbox->emitLink = cg.objectList.lastbox;
             cg.objectList.lastbox = funbox;
             cg.objectList.length++;
         }
     }
 
     /*
      * Inline Statements to emit as we go to save AST space. We must generate
      * our script-body blockid since we aren't calling Statements.
      */
     uint32 bodyid;
     if (!GenerateBlockId(&cg, bodyid))
-        return NULL;
+        goto out;
     cg.bodyid = bodyid;
 
-    /* Null script early in case of error, to reduce our code footprint. */
-    script = NULL;
 #if JS_HAS_XML_SUPPORT
     pn = NULL;
-    bool onlyXML = true;
+    bool onlyXML;
+    onlyXML = true;
 #endif
 
     for (;;) {
         jsc.tokenStream.flags |= TSF_OPERAND;
         tt = js_PeekToken(cx, &jsc.tokenStream);
         jsc.tokenStream.flags &= ~TSF_OPERAND;
         if (tt <= TOK_EOF) {
             if (tt == TOK_EOF)