Fix for bug 717009 (Inline ListBase<LC>::instanceIsListObject and ListBase<LC>::getListObject). r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Wed, 09 Nov 2011 11:37:47 +0100
changeset 85592 12a483042e9ae8100e0b69f93aab212541f52b34
parent 85591 bc777c65c5ca7cf12f605489e63371b6c07024ff
child 85593 e2235de2b8e60ae40e12cb05aa6dd8ae1fb186d5
push id21940
push userjdrew@mozilla.com
push dateSun, 29 Jan 2012 02:43:03 +0000
treeherdermozilla-central@ec666b4c8d84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs717009
milestone12.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
Fix for bug 717009 (Inline ListBase<LC>::instanceIsListObject and ListBase<LC>::getListObject). r=bz.
js/xpconnect/src/dombindings.cpp
js/xpconnect/src/dombindings.h
--- a/js/xpconnect/src/dombindings.cpp
+++ b/js/xpconnect/src/dombindings.cpp
@@ -301,29 +301,37 @@ ListBase<LC>::getProtoShape(JSObject *ob
 template<class LC>
 void
 ListBase<LC>::setProtoShape(JSObject *obj, js::Shape *shape)
 {
     JS_ASSERT(objIsList(obj));
     js::SetProxyExtra(obj, JSPROXYSLOT_PROTOSHAPE, PrivateValue(shape));
 }
 
+static JSBool
+UnwrapSecurityWrapper(JSContext *cx, JSObject *obj, JSObject *callee, JSObject **unwrapped)
+{
+    JS_ASSERT(XPCWrapper::IsSecurityWrapper(obj));
+
+    if (callee && JS_GetGlobalForObject(cx, obj) == JS_GetGlobalForObject(cx, callee)) {
+        *unwrapped = js::UnwrapObject(obj);
+    } else {
+        *unwrapped = XPCWrapper::Unwrap(cx, obj);
+        if (!*unwrapped)
+            return Throw(cx, NS_ERROR_XPC_SECURITY_MANAGER_VETO);
+    }
+    return true;
+}
+
 template<class LC>
 bool
 ListBase<LC>::instanceIsListObject(JSContext *cx, JSObject *obj, JSObject *callee)
 {
-    if (XPCWrapper::IsSecurityWrapper(obj)) {
-        if (callee && JS_GetGlobalForObject(cx, obj) == JS_GetGlobalForObject(cx, callee)) {
-            obj = js::UnwrapObject(obj);
-        } else {
-            obj = XPCWrapper::Unwrap(cx, obj);
-            if (!obj)
-                return Throw(cx, NS_ERROR_XPC_SECURITY_MANAGER_VETO);
-        }
-    }
+    if (XPCWrapper::IsSecurityWrapper(obj) && !UnwrapSecurityWrapper(cx, obj, callee, &obj))
+        return false;
 
     if (!objIsList(obj)) {
         // FIXME: Throw a proper DOM exception.
         JS_ReportError(cx, "type error: wrong object");
         return false;
     }
     return true;
 }
--- a/js/xpconnect/src/dombindings.h
+++ b/js/xpconnect/src/dombindings.h
@@ -241,22 +241,22 @@ public:
     void finalize(JSContext *cx, JSObject *proxy);
 
     static bool proxyHandlerIsList(js::ProxyHandler *handler) {
         return handler == &instance;
     }
     static bool objIsList(JSObject *obj) {
         return js::IsProxy(obj) && proxyHandlerIsList(js::GetProxyHandler(obj));
     }
-    static bool instanceIsListObject(JSContext *cx, JSObject *obj, JSObject *callee);
+    static inline bool instanceIsListObject(JSContext *cx, JSObject *obj, JSObject *callee);
     virtual bool isInstanceOf(JSObject *prototype)
     {
         return js::GetObjectClass(prototype) == &sInterfaceClass;
     }
-    static ListType *getListObject(JSObject *obj);
+    static inline ListType *getListObject(JSObject *obj);
 
     static JSObject *getPrototype(JSContext *cx, XPCWrappedNativeScope *scope);
     static inline bool protoIsClean(JSContext *cx, JSObject *proto, bool *isClean);
     static bool shouldCacheProtoShape(JSContext *cx, JSObject *proto, bool *shouldCache);
     static bool resolveNativeName(JSContext *cx, JSObject *proxy, jsid id,
                                   JSPropertyDescriptor *desc);
     static bool nativeGet(JSContext *cx, JSObject *proxy, JSObject *proto, jsid id, bool *found,
                           JS::Value *vp);