Bug 1424647: Prevent race on AllPromiseHolder::mPromise. r=jwwang

If any of the promises gets resolved/rejected prior MozPromise::All completing, it would return nullptr

MozReview-Commit-ID: Lqhv2t2upvF

--HG--
extra : rebase_source : 0c85172958c00a2ac3aa0bd33e4e50dd1893c3ba
This commit is contained in:
Jean-Yves Avenard 2017-12-10 23:31:04 +01:00
Родитель 6c3e4bfaae
Коммит a1172cfb0e
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -341,13 +341,14 @@ public:
}
RefPtr<AllPromiseHolder> holder = new AllPromiseHolder(aPromises.Length());
RefPtr<AllPromiseType> promise = holder->Promise();
for (size_t i = 0; i < aPromises.Length(); ++i) {
aPromises[i]->Then(aProcessingTarget, __func__,
[holder, i] (ResolveValueType aResolveValue) -> void { holder->Resolve(i, Move(aResolveValue)); },
[holder] (RejectValueType aRejectValue) -> void { holder->Reject(Move(aRejectValue)); }
);
}
return holder->Promise();
return promise;
}
class Request : public MozPromiseRefcountable