mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/xpmdec: Move allocations down after more error checks
Fixes: Timeout
Fixes: 37035/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XPM_fuzzer-5142718576721920
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e58692837c
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
e4e6a3fbcc
commit
5e73b973c5
|
@ -341,9 +341,6 @@ static int xpm_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
|
if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (cpp <= 0 || cpp >= 5) {
|
if (cpp <= 0 || cpp >= 5) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "unsupported/invalid number of chars per pixel: %d\n", cpp);
|
av_log(avctx, AV_LOG_ERROR, "unsupported/invalid number of chars per pixel: %d\n", cpp);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
@ -360,14 +357,17 @@ static int xpm_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
|
|
||||||
size *= 4;
|
size *= 4;
|
||||||
|
|
||||||
av_fast_padded_malloc(&x->pixels, &x->pixels_size, size);
|
|
||||||
if (!x->pixels)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
ptr += mod_strcspn(ptr, ",") + 1;
|
ptr += mod_strcspn(ptr, ",") + 1;
|
||||||
if (end - ptr < 1)
|
if (end - ptr < 1)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
av_fast_padded_malloc(&x->pixels, &x->pixels_size, size);
|
||||||
|
if (!x->pixels)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
for (i = 0; i < ncolors; i++) {
|
for (i = 0; i < ncolors; i++) {
|
||||||
const uint8_t *index;
|
const uint8_t *index;
|
||||||
int len;
|
int len;
|
||||||
|
|
Loading…
Reference in New Issue