avcodec/apedec: Allocate decoded_buffer after successful ff_get_buffer()
We need to reset samples in this case to avoid being stuck with incorrect samples value. Fixes: OOM Fixes: Timeout Fixes: 16627/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5638059583864832 Fixes: 17089/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5672188463546368 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:
parent
1e95a3e8a7
commit
cf41da2ad2
@ -1497,6 +1497,14 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
|
||||
/* reallocate decoded sample buffer if needed */
|
||||
decoded_buffer_size = 2LL * FFALIGN(blockstodecode, 8) * sizeof(*s->decoded_buffer);
|
||||
av_assert0(decoded_buffer_size <= INT_MAX);
|
||||
|
||||
/* get output buffer */
|
||||
frame->nb_samples = blockstodecode;
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
|
||||
s->samples=0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
av_fast_malloc(&s->decoded_buffer, &s->decoded_size, decoded_buffer_size);
|
||||
if (!s->decoded_buffer)
|
||||
return AVERROR(ENOMEM);
|
||||
@ -1504,11 +1512,6 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,
|
||||
s->decoded[0] = s->decoded_buffer;
|
||||
s->decoded[1] = s->decoded_buffer + FFALIGN(blockstodecode, 8);
|
||||
|
||||
/* get output buffer */
|
||||
frame->nb_samples = blockstodecode;
|
||||
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
s->error=0;
|
||||
|
||||
if ((s->channels == 1) || (s->frameflags & APE_FRAMECODE_PSEUDO_STEREO))
|
||||
|
Loading…
x
Reference in New Issue
Block a user