Panic if JS_NewObjectWithGivenProto fails.

This commit is contained in:
Ms2ger 2015-01-25 21:23:12 +01:00
parent 5f5381e4c1
commit 46e4ac280f

View file

@ -63,10 +63,6 @@ pub unsafe extern fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, i
} }
let expando = EnsureExpandoObject(cx, proxy); let expando = EnsureExpandoObject(cx, proxy);
if expando.is_null() {
return false;
}
return JS_DefinePropertyById(cx, expando, id, (*desc).value, (*desc).getter, return JS_DefinePropertyById(cx, expando, id, (*desc).value, (*desc).getter,
(*desc).setter, (*desc).attrs) != 0; (*desc).setter, (*desc).attrs) != 0;
} }
@ -115,9 +111,7 @@ pub fn EnsureExpandoObject(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObj
expando = JS_NewObjectWithGivenProto(cx, ptr::null_mut(), expando = JS_NewObjectWithGivenProto(cx, ptr::null_mut(),
ptr::null_mut(), ptr::null_mut(),
GetObjectParent(obj)); GetObjectParent(obj));
if expando.is_null() { assert!(!expando.is_null());
return ptr::null_mut();
}
SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(&*expando)); SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(&*expando));
} }