Bug 857439 Followup: Add null-checks for WrapObject failing and assert that the JSObject took ownership if WrapObject succeeded r=bz

This commit is contained in:
David Zbarsky 2013-04-19 18:18:31 -04:00
parent d572cd5e8f
commit 5dda7256e6

View File

@ -630,6 +630,10 @@ WrapNewBindingNonWrapperCachedObject(JSContext* cx, JSObject* scope, T* value,
obj = value->WrapObject(cx, scope);
}
if (!obj) {
return false;
}
// We can end up here in all sorts of compartments, per above. Make
// sure to JS_WrapValue!
*vp = JS::ObjectValue(*obj);
@ -660,11 +664,18 @@ WrapNewBindingNonWrapperCachedOwnedObject(JSContext* cx, JSObject* scope,
bool tookOwnership = false;
obj = value->WrapObject(cx, scope, &tookOwnership);
if (obj) {
MOZ_ASSERT(tookOwnership);
}
if (tookOwnership) {
value.forget();
}
}
if (!obj) {
return false;
}
// We can end up here in all sorts of compartments, per above. Make
// sure to JS_WrapValue!
*vp = JS::ObjectValue(*obj);