diff mbox series

[FFmpeg-devel,20/45] avcodec/xxan: Cleanup generically on init failure

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

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/xxan.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

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

Assent
diff mbox series

Patch

diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c
index afe60e1564..865dfa8f87 100644
--- a/libavcodec/xxan.c
+++ b/libavcodec/xxan.c
@@ -71,16 +71,12 @@  static av_cold int xan_decode_init(AVCodecContext *avctx)
     if (!s->y_buffer)
         return AVERROR(ENOMEM);
     s->scratch_buffer = av_malloc(s->buffer_size + 130);
-    if (!s->scratch_buffer) {
-        xan_decode_end(avctx);
+    if (!s->scratch_buffer)
         return AVERROR(ENOMEM);
-    }
 
     s->pic = av_frame_alloc();
-    if (!s->pic) {
-        xan_decode_end(avctx);
+    if (!s->pic)
         return AVERROR(ENOMEM);
-    }
 
     return 0;
 }
@@ -447,4 +443,5 @@  AVCodec ff_xan_wc4_decoder = {
     .close          = xan_decode_end,
     .decode         = xan_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };