diff --git a/js/xpconnect/src/XPCJSID.cpp b/js/xpconnect/src/XPCJSID.cpp index 4a319520119e..7ac5ed770386 100644 --- a/js/xpconnect/src/XPCJSID.cpp +++ b/js/xpconnect/src/XPCJSID.cpp @@ -657,8 +657,10 @@ nsJSCID::CreateInstance(HandleValue iidval, JSContext* cx, rv = compMgr->CreateInstance(mDetails->ID(), nullptr, *iid, getter_AddRefs(inst)); MOZ_ASSERT(NS_FAILED(rv) || inst, "component manager returned success, but instance is null!"); - if (NS_FAILED(rv) || !inst) - return NS_ERROR_XPC_CI_RETURNED_FAILURE; + NS_ENSURE_SUCCESS(rv, NS_ERROR_XPC_CI_RETURNED_FAILURE); + if (!inst) { + return NS_ERROR_XPC_CI_RETURNED_FAILURE; + } rv = nsContentUtils::WrapNative(cx, inst, iid, retval); if (NS_FAILED(rv) || retval.isPrimitive()) @@ -692,8 +694,11 @@ nsJSCID::GetService(HandleValue iidval, JSContext* cx, uint8_t optionalArgc, nsCOMPtr srvc; rv = svcMgr->GetService(mDetails->ID(), *iid, getter_AddRefs(srvc)); MOZ_ASSERT(NS_FAILED(rv) || srvc, "service manager returned success, but service is null!"); - if (NS_FAILED(rv) || !srvc) + + NS_ENSURE_SUCCESS(rv, NS_ERROR_XPC_GS_RETURNED_FAILURE); + if (!srvc) { return NS_ERROR_XPC_GS_RETURNED_FAILURE; + } RootedValue v(cx); rv = nsContentUtils::WrapNative(cx, srvc, iid, &v);