Bug 908891 - Fix remaining exact rooting hazards in js/ipc; r=evilpie
authorTerrence Cole <terrence@mozilla.com>
Fri, 23 Aug 2013 15:53:46 -0700
changeset 144190 c1298dc3fa4ff2a44ec75eae0512fbae0756a95e
parent 144189 3a63aeafa1833599217cbf88667d490624a74455
child 144191 19041078dfe4042b48e5a40c85e0b8880d507a26
push id25153
push userphilringnalda@gmail.com
push dateSun, 25 Aug 2013 15:20:47 +0000
treeherdermozilla-central@133348d717a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs908891
milestone26.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 908891 - Fix remaining exact rooting hazards in js/ipc; r=evilpie
js/ipc/JavaScriptParent.cpp
js/ipc/JavaScriptShared.cpp
--- a/js/ipc/JavaScriptParent.cpp
+++ b/js/ipc/JavaScriptParent.cpp
@@ -390,17 +390,17 @@ JavaScriptParent::call(JSContext *cx, Ha
 
     InfallibleTArray<JSParam> vals;
     AutoValueVector outobjects(cx);
 
     RootedValue v(cx);
     for (size_t i = 0; i < args.length() + 2; i++) {
         v = args.base()[i];
         if (v.isObject()) {
-            JSObject *obj = &v.toObject();
+            RootedObject obj(cx, &v.toObject());
             if (xpc::IsOutObject(cx, obj)) {
                 // Make sure it is not an in-out object.
                 bool found;
                 if (!JS_HasProperty(cx, obj, "value", &found))
                     return false;
                 if (found) {
                     JS_ReportError(cx, "in-out objects cannot be sent via CPOWs yet");
                     return false;
@@ -549,38 +549,39 @@ JavaScriptParent::getPropertyNames(JSCon
     }
 
     return true;
 }
 
 JSObject *
 JavaScriptParent::unwrap(JSContext *cx, ObjectId objId)
 {
-    if (JSObject *obj = findObject(objId)) {
-        if (!JS_WrapObject(cx, &obj))
+    RootedObject obj(cx, findObject(objId));
+    if (obj) {
+        if (!JS_WrapObject(cx, obj.address()))
             return NULL;
         return obj;
     }
 
     if (objId > MAX_CPOW_IDS) {
         JS_ReportError(cx, "unusable CPOW id");
         return NULL;
     }
 
     bool callable = !!(objId & OBJECT_IS_CALLABLE);
 
     RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
 
     RootedValue v(cx, UndefinedValue());
-    JSObject *obj = NewProxyObject(cx,
-                                   &CPOWProxyHandler::singleton,
-                                   v,
-                                   NULL,
-                                   global,
-                                   callable ? ProxyIsCallable : ProxyNotCallable);
+    obj = NewProxyObject(cx,
+                         &CPOWProxyHandler::singleton,
+                         v,
+                         NULL,
+                         global,
+                         callable ? ProxyIsCallable : ProxyNotCallable);
     if (!obj)
         return NULL;
 
     if (!objects_.add(objId, obj))
         return NULL;
 
     // Incref once we know the decref will be called.
     incref();
--- a/js/ipc/JavaScriptShared.cpp
+++ b/js/ipc/JavaScriptShared.cpp
@@ -163,17 +163,17 @@ JavaScriptShared::toVariant(JSContext *c
       {
         *to = uint64_t(0);
         return true;
       }
 
       case JSTYPE_OBJECT:
       case JSTYPE_FUNCTION:
       {
-        JSObject *obj = from.toObjectOrNull();
+        RootedObject obj(cx, from.toObjectOrNull());
         if (!obj) {
             JS_ASSERT(from == JSVAL_NULL);
             *to = uint64_t(0);
             return true;
         }
 
         if (xpc_JSObjectIsID(cx, obj)) {
             JSIID iid;