]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/hcom.c
fftools/ffmpeg: make specifying thread_queue_size turn on threaded input
[ffmpeg] / libavcodec / hcom.c
index 8753486c02f5d04266abe7596c25dac3022e523e..8300676f98a6519af81954e9fd2097a89dcadef5 100644 (file)
@@ -52,7 +52,8 @@ static av_cold int hcom_init(AVCodecContext *avctx)
     if (avctx->extradata_size <= 7)
         return AVERROR_INVALIDDATA;
     s->dict_entries = AV_RB16(avctx->extradata);
-    if (avctx->extradata_size < s->dict_entries * 4 + 7)
+    if (avctx->extradata_size < s->dict_entries * 4 + 7 ||
+        s->dict_entries == 0)
         return AVERROR_INVALIDDATA;
     s->delta_compression = AV_RB32(avctx->extradata + 2);
     s->sample = s->first_sample = avctx->extradata[avctx->extradata_size - 1];
@@ -63,6 +64,17 @@ static av_cold int hcom_init(AVCodecContext *avctx)
     for (int i = 0; i < s->dict_entries; i++) {
         s->dict[i].l = AV_RB16(avctx->extradata + 6 + 4 * i);
         s->dict[i].r = AV_RB16(avctx->extradata + 6 + 4 * i + 2);
+        if (s->dict[i].l >= 0 &&
+            (s->dict[i].l >= s->dict_entries ||
+             s->dict[i].r >= s->dict_entries ||
+             s->dict[i].r < 0 )) {
+            av_freep(&s->dict);
+            return AVERROR_INVALIDDATA;
+        }
+    }
+    if (s->dict[0].l < 0) {
+        av_freep(&s->dict);
+        return AVERROR_INVALIDDATA;
     }
 
     avctx->sample_fmt = AV_SAMPLE_FMT_U8;