Bug 1366208: Make sure no empty RefPtr are ever stored. r=gerald

Should any error occurred while checking the tracks, we could end up with a null pointer stored in the list of track demuxers.

MozReview-Commit-ID: 13FllESrpbg

--HG--
extra : rebase_source : 335de6320c12f758858e462ed22fc9f9ffe8e305
This commit is contained in:
Jean-Yves Avenard 2017-05-19 11:55:16 +02:00
parent d6aa91ebe4
commit fb5df1656c

View File

@ -187,7 +187,6 @@ MP4Demuxer::Init()
}
if (audioTrackCount.Ref() != 0) {
mAudioDemuxers.SetLength(audioTrackCount.Ref());
for (size_t i = 0; i < audioTrackCount.Ref(); i++) {
mp4_demuxer::MP4Metadata::ResultAndTrackInfo info =
metadata.GetTrackInfo(TrackInfo::kAudioTrack, i);
@ -216,13 +215,12 @@ MP4Demuxer::Init()
}
continue;
}
mAudioDemuxers[i] =
new MP4TrackDemuxer(this, Move(info.Ref()), *indices.Ref().get());
mAudioDemuxers.AppendElement(
new MP4TrackDemuxer(this, Move(info.Ref()), *indices.Ref().get()));
}
}
if (videoTrackCount.Ref() != 0) {
mVideoDemuxers.SetLength(videoTrackCount.Ref());
for (size_t i = 0; i < videoTrackCount.Ref(); i++) {
mp4_demuxer::MP4Metadata::ResultAndTrackInfo info =
metadata.GetTrackInfo(TrackInfo::kVideoTrack, i);
@ -251,8 +249,8 @@ MP4Demuxer::Init()
}
continue;
}
mVideoDemuxers[i] =
new MP4TrackDemuxer(this, Move(info.Ref()), *indices.Ref().get());
mVideoDemuxers.AppendElement(
new MP4TrackDemuxer(this, Move(info.Ref()), *indices.Ref().get()));
}
}