Bug 937818, part 0 - Root newly created objects in Bind across ADDREF. r=bz

This commit is contained in:
Andrew McCreight 2013-12-17 19:29:56 -08:00
parent b6a2d4d7d5
commit 3f5f23664f

View File

@ -2134,18 +2134,9 @@ class CGConstructorEnabledViaFunc(CGAbstractMethod):
return " return %s(cx, obj);" % func[0]
def CreateBindingJSObject(descriptor, properties, parent):
# When we have unforgeable properties, we're going to define them
# on our object, so we have to root it when we create it, so it
# won't suddenly die while defining the unforgeables. Similarly,
# if we have members in slots we'll have to call the getters which
# could also GC.
needRoot = (properties.unforgeableAttrs.hasNonChromeOnly() or
properties.unforgeableAttrs.hasChromeOnly() or
descriptor.interface.hasMembersInSlots())
if needRoot:
objDecl = " JS::Rooted<JSObject*> obj(aCx);\n"
else:
objDecl = " JSObject *obj;\n"
# We don't always need to root obj, but there are a variety
# of cases where we do, so for simplicity, just always root it.
objDecl = " JS::Rooted<JSObject*> obj(aCx);\n"
if descriptor.proxy:
create = """ JS::Rooted<JS::Value> proxyPrivateVal(aCx, JS::PrivateValue(aObject));
obj = NewProxyObject(aCx, DOMProxyHandler::getInstance(),