diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 4e00692631..dfe3585e6e 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -1254,7 +1254,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, slices_info_offset = AV_RL32(avpkt->data + buf_size - 4); slice_height = AV_RL32(avpkt->data + buf_size - 8); nb_slices = AV_RL32(avpkt->data + buf_size - 12); - if (nb_slices * 8LL + slices_info_offset > buf_size - 16) + if (nb_slices * 8LL + slices_info_offset > buf_size - 16 || slice_height <= 0) return AVERROR_INVALIDDATA; } else { slice_height = height;