1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avcodec/magicyuvenc: better slice height

Fixes: Use of uninitialized value
Fixes: 71072/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_fuzzer-4835252046987264

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2024-08-19 16:25:27 +02:00
parent e758b24396
commit b08776e3ae
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -378,11 +378,14 @@ static int count_plane_slice(AVCodecContext *avctx, int n, int plane)
Slice *sl = &s->slices[n * s->planes + plane];
const uint8_t *dst = sl->slice;
PTable *counts = sl->counts;
const int slice_height = s->slice_height;
const int last_height = FFMIN(slice_height, avctx->height - n * slice_height);
const int height = (n < (s->nb_slices - 1)) ? slice_height : last_height;
memset(counts, 0, sizeof(sl->counts));
count_usage(dst, AV_CEIL_RSHIFT(avctx->width, s->hshift[plane]),
AV_CEIL_RSHIFT(s->slice_height, s->vshift[plane]), counts);
AV_CEIL_RSHIFT(height, s->vshift[plane]), counts);
return 0;
}