Bug 1917665 - Return early on MaybeSomething if PromiseObj is null r=smaug

Promise::CreateInfallible allows not having PromiseObj but MaybeSomething still had an invalid assertion.

MaybeSomething eventually calls MaybeReject/Resolve which safely checks PromiseObj ultimately, but why go further when we can return early.

Differential Revision: https://phabricator.services.mozilla.com/D228465
This commit is contained in:
Kagami Sascha Rosylight 2024-11-14 15:07:59 +00:00
parent 5e9b4b9fc1
commit 377f4a1431

View File

@ -423,7 +423,9 @@ class Promise : public SupportsWeakPtr {
template <typename T>
void MaybeSomething(T&& aArgument, MaybeFunc aFunc) {
MOZ_ASSERT(PromiseObj()); // It was preserved!
if (NS_WARN_IF(!PromiseObj())) {
return;
}
AutoAllowLegacyScriptExecution exemption;
AutoEntryScript aes(mGlobal, "Promise resolution or rejection");