Bug 1507093 - P2. Ensure that when returning from NotifyXPCOMShutdown we don't UAF. r=gerald

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jean-Yves Avenard 2018-11-15 12:48:02 +00:00
Родитель 6561f5d257
Коммит 5f69f9479d
1 изменённых файлов: 5 добавлений и 6 удалений

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

@ -349,16 +349,15 @@ void
MediaDecoder::NotifyXPCOMShutdown()
{
MOZ_ASSERT(NS_IsMainThread());
// NotifyXPCOMShutdown will clear its reference to mDecoder. So we must ensure
// that this MediaDecoder stays alive until completion.
RefPtr<MediaDecoder> kungFuDeathGrip = this;
if (auto owner = GetOwner()) {
owner->NotifyXPCOMShutdown();
}
MOZ_DIAGNOSTIC_ASSERT(IsShutdown());
// Don't cause grief to release builds by ensuring Shutdown()
// is always called during shutdown phase.
if (!IsShutdown()) {
} else if (!IsShutdown()) {
Shutdown();
}
MOZ_DIAGNOSTIC_ASSERT(IsShutdown());
}
MediaDecoder::~MediaDecoder()