Bug 839376 (part 11) - Fix two more easy rooting hazards. r=terrence.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 14 Feb 2013 18:54:04 -0800
changeset 128089 fb11273bd848fbb202d02b7d8d015cfe329f9207
parent 128088 e2843bae075f879996138140ef819d22c62cc757
child 128090 a3697783abdf5a3835f8df96bdd0db4f25f5e2ce
push id3384
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:42:39 +0000
treeherdermozilla-aurora@d8c97bae8521 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs839376
milestone21.0a1
Bug 839376 (part 11) - Fix two more easy rooting hazards. r=terrence.
js/src/jsdbgapi.cpp
js/src/jswrapper.cpp
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -507,27 +507,25 @@ JS_ReleaseFunctionLocalNameArray(JSConte
     cx->tempLifoAlloc().release(mark);
 }
 
 JS_PUBLIC_API(JSScript *)
 JS_GetFunctionScript(JSContext *cx, JSFunction *fun)
 {
     if (fun->isNative())
         return NULL;
-    UnrootedScript script;
     if (fun->isInterpretedLazy()) {
         RootedFunction rootedFun(cx, fun);
         AutoCompartment funCompartment(cx, rootedFun);
-        script = rootedFun->getOrCreateScript(cx);
+        UnrootedScript script = rootedFun->getOrCreateScript(cx);
         if (!script)
             MOZ_CRASH();
-    } else {
-        script = fun->nonLazyScript();
+        return script;
     }
-    return script;
+    return fun->nonLazyScript();
 }
 
 JS_PUBLIC_API(JSNative)
 JS_GetFunctionNative(JSContext *cx, JSFunction *fun)
 {
     return fun->maybeNative();
 }
 
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -372,17 +372,17 @@ js::TransparentObjectWrapper(JSContext *
     JS_ASSERT(!obj->isWrapper() || obj->getClass()->ext.innerObject);
     return Wrapper::New(cx, obj, wrappedProto, parent, &CrossCompartmentWrapper::singleton);
 }
 
 ErrorCopier::~ErrorCopier()
 {
     JSContext *cx = ac.ref().context();
     if (ac.ref().origin() != cx->compartment && cx->isExceptionPending()) {
-        Value exc = cx->getPendingException();
+        RootedValue exc(cx, cx->getPendingException());
         if (exc.isObject() && exc.toObject().isError() && exc.toObject().getPrivate()) {
             cx->clearPendingException();
             ac.destroy();
             Rooted<JSObject*> errObj(cx, &exc.toObject());
             JSObject *copyobj = js_CopyErrorObject(cx, errObj, scope);
             if (copyobj)
                 cx->setPendingException(ObjectValue(*copyobj));
         }