diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c index 68e2b8c0d6..a06203bac5 100644 --- a/libavcodec/h264_cavlc.c +++ b/libavcodec/h264_cavlc.c @@ -773,6 +773,10 @@ decode_intra_mb: // We assume these blocks are very rare so we do not optimize it. h->intra_pcm_ptr = align_get_bits(&h->gb); + if (get_bits_left(&h->gb) < mb_size) { + av_log(h->avctx, AV_LOG_ERROR, "Not enough data for an intra PCM block.\n"); + return AVERROR_INVALIDDATA; + } skip_bits_long(&h->gb, mb_size); // In deblocking, the quantizer is 0