1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-02-14 22:22:59 +02:00

avcodec/flashsv2enc: Check allocations for success before usage

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit 319dbcf4402978f7a493b81d0f61be7a46ddbeba)
This commit is contained in:
Andreas Rheinhardt 2020-09-14 16:56:13 +02:00
parent 140d871e08
commit f8747758bb

View File

@ -231,6 +231,13 @@ static av_cold int flashsv2_encode_init(AVCodecContext * avctx)
s->key_frame = av_mallocz(s->frame_size);
s->frame_blocks = av_mallocz(s->blocks_size);
s->key_blocks = av_mallocz(s->blocks_size);
if (!s->encbuffer || !s->keybuffer || !s->databuffer
|| !s->current_frame || !s->key_frame || !s->key_blocks
|| !s->frame_blocks) {
av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n");
cleanup(s);
return AVERROR(ENOMEM);
}
s->blockbuffer = NULL;
s->blockbuffer_size = 0;
@ -245,14 +252,6 @@ static av_cold int flashsv2_encode_init(AVCodecContext * avctx)
s->use_custom_palette = 0;
s->palette_type = -1; // so that the palette will be generated in reconfigure_at_keyframe
if (!s->encbuffer || !s->keybuffer || !s->databuffer
|| !s->current_frame || !s->key_frame || !s->key_blocks
|| !s->frame_blocks) {
av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n");
cleanup(s);
return -1;
}
return 0;
}