]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/decode: Check max_samples in get_buffer_internal()
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 25 Sep 2019 14:18:32 +0000 (16:18 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 25 Sep 2019 15:21:23 +0000 (17:21 +0200)
This checks max_samples at the same level as max_pixels

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/decode.c

index a9ea5a51e65f893139eac9af4540a39cea6392b9..081847551e52d89cc1fbe216d73edac123f315b6 100644 (file)
@@ -1924,6 +1924,11 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
             av_log(avctx, AV_LOG_ERROR, "pic->data[*]!=NULL in get_buffer_internal\n");
             return AVERROR(EINVAL);
         }
+    } else if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+        if (frame->nb_samples > avctx->max_samples) {
+            av_log(avctx, AV_LOG_ERROR, "samples per frame %d, exceeds max_samples %"PRId64"\n", frame->nb_samples, avctx->max_samples);
+            return AVERROR(EINVAL);
+        }
     }
     ret = ff_decode_frame_props(avctx, frame);
     if (ret < 0)