[FFmpeg-devel,1/2] lavc/hevc_mp4toannexb_bsf: don't fail on extradata with too few arrays

Submitted by Rodger Combs on Aug. 23, 2018, 9:37 p.m.

Details

Message ID 20180823213753.36856-1-rodger.combs@gmail.com
State New
Headers show

Commit Message

Rodger Combs Aug. 23, 2018, 9:37 p.m.
I've been given a sample that does this. Not sure exactly why, but the decoder
ignores it and plays normally.
---
 libavcodec/hevc_mp4toannexb_bsf.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c
index 09bce5b34c..fb4ea34a93 100644
--- a/libavcodec/hevc_mp4toannexb_bsf.c
+++ b/libavcodec/hevc_mp4toannexb_bsf.c
@@ -52,6 +52,11 @@  static int hevc_extradata_to_annexb(AVBSFContext *ctx)
     num_arrays  = bytestream2_get_byte(&gb);
 
     for (i = 0; i < num_arrays; i++) {
+        if (bytestream2_get_bytes_left(&gb) < 3) {
+            av_log(ctx, AV_LOG_WARNING, "Extradata contained fewer arrays than indicated\n");
+            break;
+        }
+
         int type = bytestream2_get_byte(&gb) & 0x3f;
         int cnt  = bytestream2_get_be16(&gb);