Bug 787856 - Use static JSObject::getProto in proxy code; r=wmccloskey
authorEddy Bruel <ejpbruel@mozilla.com>
Sun, 30 Sep 2012 17:51:26 +0200
changeset 108802 22c9c298a21f902bc8f798ffa7f244d7d064b12a
parent 108801 fc074c4155138d8065efa082171d247320420740
child 108803 12465a1211e0e3489938426295b4988906947036
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewerswmccloskey
bugs787856
milestone18.0a1
Bug 787856 - Use static JSObject::getProto in proxy code; r=wmccloskey
js/src/jsproxy.cpp
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -1598,17 +1598,19 @@ ScriptedDirectProxyHandler::getPropertyD
 {
     JS_CHECK_RECURSION(cx, return false);
     Rooted<JSObject*> proxy(cx, proxy_);
     Rooted<jsid> id(cx, id_);
     if (!GetOwnPropertyDescriptor(cx, proxy, id, desc))
         return false;
     if (desc->obj)
         return true;
-    JSObject *proto = proxy->getProto();
+    RootedObject proto(cx);
+    if (!JSObject::getProto(cx, proxy, &proto))
+        return false;
     if (!proto) {
         JS_ASSERT(!desc->obj);
         return true;
     }
     return JS_GetPropertyDescriptorById(cx, proto, id, JSRESOLVE_QUALIFIED, desc);
 }
 
 bool
@@ -3120,24 +3122,26 @@ static JSBool
 proxy(JSContext *cx, unsigned argc, jsval *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() < 2) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_MORE_ARGS_NEEDED,
                              "Proxy", "1", "s");
         return false;
     }
-    JSObject *target = NonNullObject(cx, args[0]);
+    RootedObject target(cx, NonNullObject(cx, args[0]));
     if (!target)
         return false;
-    JSObject *handler = NonNullObject(cx, args[1]);
+    RootedObject handler(cx, NonNullObject(cx, args[1]));
     if (!handler)
         return false;
-    JSObject *proto = target->getProto();
-    JSObject *fun = target->isCallable() ? target : NULL;
+    RootedObject proto(cx);
+    if (!JSObject::getProto(cx, target, &proto))
+        return false;
+    RootedObject fun(cx, target->isCallable() ? target : (JSObject *) NULL);
     JSObject *proxy = NewProxyObject(cx, &ScriptedDirectProxyHandler::singleton,
                                      ObjectValue(*target), proto, proto->getParent(),
                                      fun, fun);
     if (!proxy)
         return false;
     SetProxyExtra(proxy, 0, ObjectOrNullValue(handler));
     vp->setObject(*proxy);
     return true;