diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c index a162fc7da3..27eed415d1 100644 --- a/libavcodec/cfhd.c +++ b/libavcodec/cfhd.c @@ -963,6 +963,15 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, } low = s->plane[plane].l_h[6]; high = s->plane[plane].l_h[7]; + + if (avctx->pix_fmt == AV_PIX_FMT_BAYER_RGGB16 && + (lowpass_height * 2 > avctx->coded_height / 2 || + lowpass_width * 2 > avctx->coded_width / 2 ) + ) { + ret = AVERROR_INVALIDDATA; + goto end; + } + for (i = 0; i < lowpass_height * 2; i++) { if (avctx->pix_fmt == AV_PIX_FMT_BAYER_RGGB16) horiz_filter_clip_bayer(dst, low, high, lowpass_width, s->bpc);