diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 5649ec3bac..3240aee53a 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -1761,19 +1761,20 @@ static av_cold int ac3_encode_init(AVCodecContext *avctx) s->mdct.avctx = avctx; ret = mdct_init(&s->mdct, 9); if (ret) { - ac3_encode_close(avctx); - return ret; + goto init_fail; } ret = allocate_buffers(avctx); if (ret) { - ac3_encode_close(avctx); - return ret; + goto init_fail; } avctx->coded_frame= avcodec_alloc_frame(); return 0; +init_fail: + ac3_encode_close(avctx); + return ret; }