1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/cngenc: Cleanup generically after init failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2020-09-14 02:00:11 +02:00
parent 29c5c8fdfb
commit 2fd3ada931

View File

@ -58,10 +58,8 @@ static av_cold int cng_encode_init(AVCodecContext *avctx)
return ret;
p->samples32 = av_malloc_array(avctx->frame_size, sizeof(*p->samples32));
p->ref_coef = av_malloc_array(p->order, sizeof(*p->ref_coef));
if (!p->samples32 || !p->ref_coef) {
cng_encode_close(avctx);
if (!p->samples32 || !p->ref_coef)
return AVERROR(ENOMEM);
}
return 0;
}
@ -113,4 +111,5 @@ AVCodec ff_comfortnoise_encoder = {
.close = cng_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};