Bug 1226842: Error rather than asserting when encountering error in sample table. r=gerald
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 01 Dec 2015 11:37:42 +1100
changeset 275140 f0979ce60a871f6e892acaf29c473108cc215a7d
parent 275139 76b10dad2e3d3090d73f7911b23dd68243a2d556
child 275141 f6e234ee862b570b9817fffe77d40cb03784166e
push id29747
push usercbook@mozilla.com
push dateWed, 02 Dec 2015 14:21:19 +0000
treeherdermozilla-central@f6ac392322b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1226842
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1226842: Error rather than asserting when encountering error in sample table. r=gerald
media/libstagefright/frameworks/av/media/libstagefright/SampleIterator.cpp
--- a/media/libstagefright/frameworks/av/media/libstagefright/SampleIterator.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/SampleIterator.cpp
@@ -78,17 +78,19 @@ status_t SampleIterator::seekTo(uint32_t
     if (sampleIndex >= mStopChunkSampleIndex) {
         status_t err;
         if ((err = findChunkRange(sampleIndex)) != OK) {
             ALOGE("findChunkRange failed");
             return err;
         }
     }
 
-    CHECK(sampleIndex < mStopChunkSampleIndex);
+    if (sampleIndex >= mStopChunkSampleIndex) {
+        return ERROR_MALFORMED;
+    }
 
     uint32_t chunk =
         (sampleIndex - mFirstChunkSampleIndex) / mSamplesPerChunk
         + mFirstChunk;
 
     if (!mInitialized || chunk != mCurrentChunkIndex) {
         mCurrentChunkIndex = chunk;
 
@@ -111,21 +113,24 @@ status_t SampleIterator::seekTo(uint32_t
                 ALOGE("getSampleSizeDirect return error");
                 return err;
             }
 
             mCurrentChunkSampleSizes.push(sampleSize);
         }
     }
 
-    CHECK(mCurrentChunkSampleSizes.size() == mSamplesPerChunk);
+    if (mCurrentChunkSampleSizes.size() != mSamplesPerChunk) {
+        return ERROR_MALFORMED;
+    }
 
     uint32_t chunkRelativeSampleIndex =
         (sampleIndex - mFirstChunkSampleIndex) % mSamplesPerChunk;
 
+    // This can never happen unless % operator is buggy.
     CHECK(chunkRelativeSampleIndex < mSamplesPerChunk);
 
     mCurrentSampleOffset = mCurrentChunkOffset;
     for (uint32_t i = 0; i < chunkRelativeSampleIndex; ++i) {
         mCurrentSampleOffset += mCurrentChunkSampleSizes[i];
     }
 
     mCurrentSampleSize = mCurrentChunkSampleSizes[chunkRelativeSampleIndex];