Bug 783702 - Call through to get() for hasPrototype() path in getElementIfPresent(). r=ejpbruel
authorBobby Holley <bobbyholley@gmail.com>
Mon, 24 Sep 2012 12:05:50 +0200
changeset 108005 3d8bdbcc40f906dfd4edf69c0235ce549528db3f
parent 108004 d678fc7cfbefc491306f05eba987cf3b43b6ac6b
child 108006 46fce5a9890f2fef138ed96b7065aad0a1c67948
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersejpbruel
bugs783702
milestone18.0a1
Bug 783702 - Call through to get() for hasPrototype() path in getElementIfPresent(). r=ejpbruel
js/src/jsproxy.cpp
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -2380,21 +2380,24 @@ Proxy::get(JSContext *cx, HandleObject p
 bool
 Proxy::getElementIfPresent(JSContext *cx, HandleObject proxy_, HandleObject receiver, uint32_t index,
                            MutableHandleValue vp, bool *present)
 {
     JS_CHECK_RECURSION(cx, return false);
     RootedObject proxy(cx, proxy_);
     BaseProxyHandler *handler = GetProxyHandler(proxy);
     bool hasOwn, status = true;
-    if (!handler->hasPrototype() ||
-        ((status = handler->hasOwn(cx, proxy, INT_TO_JSID(index), &hasOwn)) && hasOwn))
+    RootedId id(cx);
+    if (!handler->hasPrototype()) {
+        return GetProxyHandler(proxy)->getElementIfPresent(cx, proxy, receiver, index, vp.address(), present);
+    } else if (status = IndexToId(cx, index, id.address()) &&
+               (status = handler->hasOwn(cx, proxy, id, &hasOwn)) && hasOwn)
     {
-        return GetProxyHandler(proxy)->getElementIfPresent(cx, proxy, receiver,
-                                                           index, vp.address(), present);
+        *present = true;
+        return GetProxyHandler(proxy)->get(cx, proxy, receiver, id, vp.address());
     } else if (!status) {
         return false;
     }
     INVOKE_ON_PROTOTYPE(cx, handler, proxy,
                         JSObject::getElementIfPresent(cx, proto, receiver, index, vp, present));
 }
 
 bool