Bug 1621779 - Make sure BrowsingContext exists before using it. r=alwu

A declare of a pointer in the init-statement within if need to be
checked if it's a NULL before it's being used, to avoid a potential
crash.

To prevent any goes wrong in mMediaSessionInfoMap and lead to create a
null BrowsingContext pointer from it, using an assertion is more
straightforward.

Differential Revision: https://phabricator.services.mozilla.com/D66491

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Chun-Min Chang 2020-03-19 17:53:42 +00:00
Родитель b95018d119
Коммит ce0d9c74e7
1 изменённых файлов: 3 добавлений и 2 удалений

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

@ -105,8 +105,9 @@ void MediaSessionController::UpdateActiveMediaSessionContextId() {
for (auto iter = mMediaSessionInfoMap.ConstIter(); !iter.Done();
iter.Next()) {
if (RefPtr<BrowsingContext> bc = BrowsingContext::Get(iter.Key());
bc->IsTopContent()) {
RefPtr<BrowsingContext> bc = BrowsingContext::Get(iter.Key());
MOZ_ASSERT(bc);
if (bc->IsTopContent()) {
candidateId = iter.Key();
break;
}