Bug 1325707: P1. Check returned value. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 06 Feb 2017 15:46:18 +0100
changeset 479411 7acead4b2311ef7a47d56f5aa5c0b49b9af4d53f
parent 479331 ddc0fda6cc9921d7a5a2a96912587233a5ce56a0
child 479412 5f97405f13c9a48c76065cc0d8e0b1a90086bac3
push id44244
push userbmo:jyavenard@mozilla.com
push dateMon, 06 Feb 2017 16:32:25 +0000
reviewersgerald
bugs1325707
milestone54.0a1
Bug 1325707: P1. Check returned value. r?gerald This is really just for cleanliness perspective, as it can never happen, we always check that demuxing a packet succeeded first. MozReview-Commit-ID: FQ1yz16m9Ix
dom/media/ogg/OggCodecState.cpp
dom/media/ogg/OggDemuxer.cpp
--- a/dom/media/ogg/OggCodecState.cpp
+++ b/dom/media/ogg/OggCodecState.cpp
@@ -1300,16 +1300,19 @@ OpusState::PacketOutAsMediaRawData()
   uint32_t frames = 0;
   const int64_t endFrame = packet->granulepos;
 
   if (packet->e_o_s) {
     frames = GetOpusDeltaGP(packet);
   }
 
   RefPtr<MediaRawData> data = OggCodecState::PacketOutAsMediaRawData();
+  if (!data) {
+    return nullptr;
+  }
 
   if (data->mEOS && mPrevPacketGranulepos != -1) {
     // If this is the last packet, perform end trimming.
     int64_t startFrame = mPrevPacketGranulepos;
     frames -= std::max<int64_t>(
       0, std::min(endFrame - startFrame, static_cast<int64_t>(frames)));
     data->mDiscardPadding = frames;
   }
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -1337,16 +1337,19 @@ OggTrackDemuxer::NextSample()
   ogg_packet* packet = mParent->GetNextPacket(mType);
   if (!packet) {
     return nullptr;
   }
   // Check the eos state in case we need to look for chained streams.
   bool eos = packet->e_o_s;
   OggCodecState* state = mParent->GetTrackCodecState(mType);
   RefPtr<MediaRawData> data = state->PacketOutAsMediaRawData();
+  if (!data) {
+    return nullptr;
+  }
   if (mType == TrackInfo::kAudioTrack) {
     data->mTrackInfo = mParent->mSharedAudioTrackInfo;
   }
   if (eos) {
     // We've encountered an end of bitstream packet; check for a chained
     // bitstream following this one.
     // This will also update mSharedAudioTrackInfo.
     mParent->ReadOggChain(TimeUnit::FromMicroseconds(data->GetEndTime()));