diff mbox series

[FFmpeg-devel,14/45] avcodec/xan: Cleanup generically on init failure

Message ID 20201127010249.2724610-14-andreas.rheinhardt@gmail.com
State Accepted
Commit 85e1d469af1ed4d4e0bb5b5f26c4cb6f60f8304a
Headers show
Series [FFmpeg-devel,01/45] avcodec/a64multienc: Fix memleak upon init failure | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 27, 2020, 1:02 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/xan.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Anton Khirnov Dec. 4, 2020, 10:59 a.m. UTC | #1
Quoting Andreas Rheinhardt (2020-11-27 02:02:18)
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/xan.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)

Looks good
diff mbox series

Patch

diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index 1ccf164847..5318aab797 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -100,16 +100,12 @@  static av_cold int xan_decode_init(AVCodecContext *avctx)
         return AVERROR(ENOMEM);
     s->buffer2_size = avctx->width * avctx->height;
     s->buffer2 = av_malloc(s->buffer2_size + 130);
-    if (!s->buffer2) {
-        av_freep(&s->buffer1);
+    if (!s->buffer2)
         return AVERROR(ENOMEM);
-    }
 
     s->last_frame = av_frame_alloc();
-    if (!s->last_frame) {
-        xan_decode_end(avctx);
+    if (!s->last_frame)
         return AVERROR(ENOMEM);
-    }
 
     return 0;
 }
@@ -649,4 +645,5 @@  AVCodec ff_xan_wc3_decoder = {
     .close          = xan_decode_end,
     .decode         = xan_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };