mirror of
https://github.com/servo/servo.git
synced 2025-06-17 04:44:28 +00:00
Avoid a null-dereference using debug mozjs builds. This matches the equivalent code upstream in Gecko.
This commit is contained in:
parent
2cfcc26d9e
commit
30d1ff6abc
1 changed files with 9 additions and 22 deletions
|
@ -2164,13 +2164,10 @@ def CreateBindingJSObject(descriptor, parent=None):
|
||||||
create += """
|
create += """
|
||||||
let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as usize];
|
let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as usize];
|
||||||
let private = RootedValue::new(cx, PrivateValue(raw as *const libc::c_void));
|
let private = RootedValue::new(cx, PrivateValue(raw as *const libc::c_void));
|
||||||
let obj = {
|
let obj = NewProxyObject(cx, handler,
|
||||||
let _ac = JSAutoCompartment::new(cx, proto.ptr);
|
private.handle(),
|
||||||
NewProxyObject(cx, handler,
|
proto.ptr, %s.get(),
|
||||||
private.handle(),
|
ptr::null_mut(), ptr::null_mut());
|
||||||
proto.ptr, %s.get(),
|
|
||||||
ptr::null_mut(), ptr::null_mut())
|
|
||||||
};
|
|
||||||
assert!(!obj.is_null());
|
assert!(!obj.is_null());
|
||||||
let obj = RootedObject::new(cx, obj);\
|
let obj = RootedObject::new(cx, obj);\
|
||||||
""" % (descriptor.name, parent)
|
""" % (descriptor.name, parent)
|
||||||
|
@ -2185,12 +2182,8 @@ let obj = RootedObject::new(cx, obj);\
|
||||||
");\n"
|
");\n"
|
||||||
"assert!(!obj.ptr.is_null());" % TRACE_HOOK_NAME)
|
"assert!(!obj.ptr.is_null());" % TRACE_HOOK_NAME)
|
||||||
else:
|
else:
|
||||||
create += ("let obj = {\n"
|
create += ("let obj = RootedObject::new(cx, JS_NewObjectWithGivenProto(\n"
|
||||||
" let _ac = JSAutoCompartment::new(cx, proto.ptr);\n"
|
" cx, &Class.base as *const js::jsapi::Class as *const JSClass, proto.handle()));\n"
|
||||||
" JS_NewObjectWithGivenProto(\n"
|
|
||||||
" cx, &Class.base as *const js::jsapi::Class as *const JSClass, proto.handle())\n"
|
|
||||||
"};\n"
|
|
||||||
"let obj = RootedObject::new(cx, obj);\n"
|
|
||||||
"assert!(!obj.ptr.is_null());\n"
|
"assert!(!obj.ptr.is_null());\n"
|
||||||
"\n"
|
"\n"
|
||||||
"JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT,\n"
|
"JS_SetReservedSlot(obj.ptr, DOM_OBJECT_SLOT,\n"
|
||||||
|
@ -2236,11 +2229,7 @@ def CopyUnforgeablePropertiesToInstance(descriptor):
|
||||||
# reflector, so we can make sure we don't get confused by named getters.
|
# reflector, so we can make sure we don't get confused by named getters.
|
||||||
if descriptor.proxy:
|
if descriptor.proxy:
|
||||||
copyCode += """\
|
copyCode += """\
|
||||||
let mut expando = RootedObject::new(cx, ptr::null_mut());
|
let expando = RootedObject::new(cx, ensure_expando_object(cx, obj.handle()));
|
||||||
{
|
|
||||||
let _ac = JSAutoCompartment::new(cx, scope.get());
|
|
||||||
expando.handle_mut().set(ensure_expando_object(cx, obj.handle()));
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
obj = "expando"
|
obj = "expando"
|
||||||
else:
|
else:
|
||||||
|
@ -2291,10 +2280,8 @@ assert!(!scope.get().is_null());
|
||||||
assert!(((*JS_GetClass(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
|
assert!(((*JS_GetClass(scope.get())).flags & JSCLASS_IS_GLOBAL) != 0);
|
||||||
|
|
||||||
let mut proto = RootedObject::new(cx, ptr::null_mut());
|
let mut proto = RootedObject::new(cx, ptr::null_mut());
|
||||||
{
|
let _ac = JSAutoCompartment::new(cx, scope.get());
|
||||||
let _ac = JSAutoCompartment::new(cx, scope.get());
|
GetProtoObject(cx, scope, scope, proto.handle_mut());
|
||||||
GetProtoObject(cx, scope, scope, proto.handle_mut())
|
|
||||||
}
|
|
||||||
assert!(!proto.ptr.is_null());
|
assert!(!proto.ptr.is_null());
|
||||||
|
|
||||||
%(createObject)s
|
%(createObject)s
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue