OSDN Git Service

stagefright-plugins: Fix crash if nal size is not 3/4
authorKeith Mok <kmok@cyngn.com>
Mon, 2 May 2016 22:23:19 +0000 (15:23 -0700)
committerKeith Mok <kmok@cyngn.com>
Mon, 2 May 2016 22:23:19 +0000 (15:23 -0700)
IF a media file reported a nal size length not
equals to 3/4. It will asserts.
Change it to report error on that media instead
of asserts.

FEIJ-335

Change-Id: Id46a423102407388eff2b7f3b069cb7c4354df32

extractor/FFmpegExtractor.cpp

index 2577b96..1a27f68 100644 (file)
@@ -1509,7 +1509,13 @@ retry:
     //copy data
     if ((mIsAVC || mIsHEVC) && mNal2AnnexB) {
         /* This only works for NAL sizes 3-4 */
-        CHECK(mNALLengthSize == 3 || mNALLengthSize == 4);
+        if ((mNALLengthSize != 3) && (mNALLengthSize != 4)) {
+            ALOGE("cannot use convertNal2AnnexB, nal size: %d", mNALLengthSize);
+            mediaBuffer->release();
+            mediaBuffer = NULL;
+            av_packet_unref(&pkt);
+            return ERROR_MALFORMED;
+        }
 
         uint8_t *dst = (uint8_t *)mediaBuffer->data();
         /* Convert H.264 NAL format to annex b */