1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

avcodec/magicyuvenc: Restrict number of slice-planes to 256

Every frame contains an array of uint8_t with values
0..(s->planes * s->nb_slices - 1), so this needs to fit
into an uint8_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-04-17 12:54:44 +02:00
parent 01bb7421a0
commit 0e4d513f99

View File

@ -206,6 +206,7 @@ static av_cold int magy_encode_init(AVCodecContext *avctx)
s->nb_slices = FFMAX(1, s->nb_slices); s->nb_slices = FFMAX(1, s->nb_slices);
s->slice_height = FFALIGN((avctx->height + s->nb_slices - 1) / s->nb_slices, 1 << s->vshift[1]); s->slice_height = FFALIGN((avctx->height + s->nb_slices - 1) / s->nb_slices, 1 << s->vshift[1]);
s->nb_slices = (avctx->height + s->slice_height - 1) / s->slice_height; s->nb_slices = (avctx->height + s->slice_height - 1) / s->slice_height;
s->nb_slices = FFMIN(256U / s->planes, s->nb_slices);
s->slices = av_calloc(s->nb_slices * s->planes, sizeof(*s->slices)); s->slices = av_calloc(s->nb_slices * s->planes, sizeof(*s->slices));
if (!s->slices) if (!s->slices)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);