Bug 1156505 - p2: Null-check sampleTable before use. r=rillian, a=sylvestre
authorGerald Squelart <gsquelart@mozilla.com>
Fri, 02 Oct 2015 16:13:00 +0200
changeset 289610 6b8a2f0f4e2e
parent 289609 1721db97f72e
child 289611 f23031e5a290
push id5219
push usercbook@mozilla.com
push date2015-10-22 08:15 +0000
treeherdermozilla-beta@6b8a2f0f4e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian, sylvestre
bugs1156505
milestone42.0
Bug 1156505 - p2: Null-check sampleTable before use. r=rillian, a=sylvestre
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -1469,34 +1469,34 @@ status_t MPEG4Extractor::parseChunk(off6
                 return ERROR_MALFORMED;
             }
             break;
         }
 
         case FOURCC('s', 't', 'c', 'o'):
         case FOURCC('c', 'o', '6', '4'):
         {
-            if (!mLastTrack) {
+            if (!mLastTrack || !mLastTrack->sampleTable.get()) {
               return ERROR_MALFORMED;
             }
             status_t err =
                 mLastTrack->sampleTable->setChunkOffsetParams(
                         chunk_type, data_offset, chunk_data_size);
 
             if (err != OK) {
                 return err;
             }
 
             *offset += chunk_size;
             break;
         }
 
         case FOURCC('s', 't', 's', 'c'):
         {
-            if (!mLastTrack) {
+            if (!mLastTrack || !mLastTrack->sampleTable.get()) {
               return ERROR_MALFORMED;
             }
             status_t err =
                 mLastTrack->sampleTable->setSampleToChunkParams(
                         data_offset, chunk_data_size);
 
             if (err != OK) {
                 return err;
@@ -1504,17 +1504,17 @@ status_t MPEG4Extractor::parseChunk(off6
 
             *offset += chunk_size;
             break;
         }
 
         case FOURCC('s', 't', 's', 'z'):
         case FOURCC('s', 't', 'z', '2'):
         {
-            if (!mLastTrack) {
+            if (!mLastTrack || !mLastTrack->sampleTable.get()) {
               return ERROR_MALFORMED;
             }
             status_t err =
                 mLastTrack->sampleTable->setSampleSizeParams(
                         chunk_type, data_offset, chunk_data_size);
 
             if (err != OK) {
                 return err;
@@ -1561,85 +1561,85 @@ status_t MPEG4Extractor::parseChunk(off6
                 }
             }
 
             break;
         }
 
         case FOURCC('s', 't', 't', 's'):
         {
-            if (!mLastTrack) {
+            if (!mLastTrack || !mLastTrack->sampleTable.get()) {
               return ERROR_MALFORMED;
             }
             status_t err =
                 mLastTrack->sampleTable->setTimeToSampleParams(
                         data_offset, chunk_data_size);
 
             if (err != OK) {
                 return err;
             }
 
             *offset += chunk_size;
             break;
         }
 
         case FOURCC('c', 't', 't', 's'):
         {
-            if (!mLastTrack) {
+            if (!mLastTrack || !mLastTrack->sampleTable.get()) {
               return ERROR_MALFORMED;
             }
             status_t err =
                 mLastTrack->sampleTable->setCompositionTimeToSampleParams(
                         data_offset, chunk_data_size);
 
             if (err != OK) {
                 return err;
             }
 
             *offset += chunk_size;
             break;
         }
 
         case FOURCC('s', 't', 's', 's'):
         {
-            if (!mLastTrack) {
+            if (!mLastTrack || !mLastTrack->sampleTable.get()) {
               return ERROR_MALFORMED;
             }
             status_t err =
                 mLastTrack->sampleTable->setSyncSampleParams(
                         data_offset, chunk_data_size);
 
             if (err != OK) {
                 return err;
             }
 
             *offset += chunk_size;
             break;
         }
 
         case FOURCC('s', 'a', 'i', 'z'):
         {
-            if (!mLastTrack) {
+            if (!mLastTrack || !mLastTrack->sampleTable.get()) {
               return ERROR_MALFORMED;
             }
             status_t err =
                 mLastTrack->sampleTable->setSampleAuxiliaryInformationSizeParams(
                         data_offset, chunk_data_size, mDrmScheme);
 
             if (err != OK) {
                 return err;
             }
 
             *offset += chunk_size;
             break;
         }
 
         case FOURCC('s', 'a', 'i', 'o'):
         {
-            if (!mLastTrack) {
+            if (!mLastTrack || !mLastTrack->sampleTable.get()) {
               return ERROR_MALFORMED;
             }
             status_t err =
                 mLastTrack->sampleTable->setSampleAuxiliaryInformationOffsetParams(
                         data_offset, chunk_data_size, mDrmScheme);
 
             if (err != OK) {
                 return err;
@@ -4240,17 +4240,17 @@ public:
   {
     return aFirst->start_composition == aSecond->start_composition;
   }
 };
 
 nsTArray<MediaSource::Indice> MPEG4Source::exportIndex()
 {
   nsTArray<MediaSource::Indice> index;
-  if (!mTimescale) {
+  if (!mTimescale || !mSampleTable.get()) {
     return index;
   }
 
   if (!index.SetCapacity(mSampleTable->countSamples(), mozilla::fallible)) {
     return index;
   }
   for (uint32_t sampleIndex = 0; sampleIndex < mSampleTable->countSamples();
           sampleIndex++) {