Bug 660638: Add NULL check to Compiler::compileScript (r=jwalden)
authorPaul Biggar <pbiggar@mozilla.com>
Mon, 06 Jun 2011 14:24:10 -0700
changeset 70975 29b7c7a1450656fef4a86e6295f8da446efa1f3b
parent 70974 ce4a984d43dce1fe3e9fdd9c204e814857f44ce2
child 70976 f1d0cfb6673f41c87eb929ef2c0f0da7f0203706
push id20463
push usercleary@mozilla.com
push dateMon, 13 Jun 2011 17:53:39 +0000
treeherdermozilla-central@872ae1cef345 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs660638
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 660638: Add NULL check to Compiler::compileScript (r=jwalden)
js/src/jsparse.cpp
--- a/js/src/jsparse.cpp
+++ b/js/src/jsparse.cpp
@@ -1128,27 +1128,28 @@ Compiler::compileScript(JSContext *cx, J
 
 #ifdef JS_ARENAMETER
     JS_DumpArenaStats(stdout);
 #endif
 
     JS_ASSERT(cg.version() == version);
 
     script = JSScript::NewScriptFromCG(cx, &cg);
-    if (script && funbox)
+    if (!script)
+        goto out;
+
+    if (funbox)
         script->savedCallerFun = true;
 
 #ifdef JS_SCOPE_DEPTH_METER
-    if (script) {
-        JSObject *obj = scopeChain;
-        uintN depth = 1;
-        while ((obj = obj->getParent()) != NULL)
-            ++depth;
-        JS_BASIC_STATS_ACCUM(&cx->runtime->hostenvScopeDepthStats, depth);
-    }
+    JSObject *obj = scopeChain;
+    uintN depth = 1;
+    while ((obj = obj->getParent()) != NULL)
+        ++depth;
+    JS_BASIC_STATS_ACCUM(&cx->runtime->hostenvScopeDepthStats, depth);
 #endif
 
     {
         AutoShapeRooter shapeRoot(cx, script->bindings.lastShape());
         if (!defineGlobals(cx, globalScope, script))
             goto late_error;
     }