Bug 1329075 - Fix potential null deref issues in media element track sources. r=jesup

MozReview-Commit-ID: ExUh2magc2z

--HG--
extra : rebase_source : 9377109b8b5881d3cc122bc0c1447019dce5e069
This commit is contained in:
Andreas Pehrson 2017-01-09 17:00:43 +01:00
Родитель 13c708b237
Коммит 03beb7fb5e
1 изменённых файлов: 21 добавлений и 4 удалений

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

@ -2936,6 +2936,11 @@ public:
CORSMode GetCORSMode() const override
{
if (!mCapturedTrackSource) {
// This could happen during shutdown.
return CORS_NONE;
}
return mCapturedTrackSource->GetCORSMode();
}
@ -2954,6 +2959,11 @@ public:
void PrincipalChanged() override
{
if (!mCapturedTrackSource) {
// This could happen during shutdown.
return;
}
mPrincipal = mCapturedTrackSource->GetPrincipal();
MediaStreamTrackSource::PrincipalChanged();
}
@ -2999,10 +3009,12 @@ public:
void Destroy() override
{
MOZ_ASSERT(mElement);
DebugOnly<bool> res = mElement->RemoveDecoderPrincipalChangeObserver(this);
NS_ASSERTION(res, "Removing decoder principal changed observer failed. "
"Had it already been removed?");
if (mElement) {
DebugOnly<bool> res = mElement->RemoveDecoderPrincipalChangeObserver(this);
NS_ASSERTION(res, "Removing decoder principal changed observer failed. "
"Had it already been removed?");
mElement = nullptr;
}
}
MediaSourceEnum GetMediaSource() const override
@ -3012,6 +3024,11 @@ public:
CORSMode GetCORSMode() const override
{
if (!mElement) {
MOZ_ASSERT(false, "Should always have an element if in use");
return CORS_NONE;
}
return mElement->GetCORSMode();
}