Bug 1127554 - Do a fallible allocation in SampleIterator::GetNext. v1 r=mattwoodrow
authorBobby Holley <bobbyholley@gmail.com>
Wed, 11 Feb 2015 15:25:26 -0800
changeset 240829 96bdae12c391e060d7678565dff5c454e4ef878e
parent 240828 7ce31efb1481b196fb8c68e9f955a11ee7464e1b
child 240830 b1e18ec6569565665cc1b3188b7256c59ac21f63
push id7666
push userbobbyholley@gmail.com
push dateSun, 22 Feb 2015 01:01:21 +0000
treeherdermozilla-aurora@b1e18ec65695 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1127554
milestone37.0a2
Bug 1127554 - Do a fallible allocation in SampleIterator::GetNext. v1 r=mattwoodrow
media/libstagefright/binding/Index.cpp
--- a/media/libstagefright/binding/Index.cpp
+++ b/media/libstagefright/binding/Index.cpp
@@ -94,17 +94,20 @@ MP4Sample* SampleIterator::GetNext()
   sample->decode_timestamp = s->mDecodeTime;
   sample->composition_timestamp = s->mCompositionRange.start;
   sample->duration = s->mCompositionRange.Length();
   sample->byte_offset = s->mByteRange.mStart;
   sample->is_sync_point = s->mSync;
   sample->size = s->mByteRange.Length();
 
   // Do the blocking read
-  sample->data = sample->extra_buffer = new uint8_t[sample->size];
+  sample->data = sample->extra_buffer = new (fallible) uint8_t[sample->size];
+  if (!sample->data) {
+    return nullptr;
+  }
 
   size_t bytesRead;
   if (!mIndex->mSource->ReadAt(sample->byte_offset, sample->data, sample->size,
                                &bytesRead) || bytesRead != sample->size) {
     return nullptr;
   }
 
   if (!s->mCencRange.IsNull()) {