diff mbox series

[FFmpeg-devel,179/217] avcodec/vqavideo: Cleanup generically on init failure

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

Checks

Context Check Description
andriy/x86 warning Failed to apply patch

Commit Message

Andreas Rheinhardt Dec. 2, 2020, 4:22 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/vqavideo.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index 05f77fd1c8..004e11ed7f 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -171,17 +171,17 @@  static av_cold int vqa_decode_init(AVCodecContext *avctx)
     s->codebook_size = MAX_CODEBOOK_SIZE;
     s->codebook = av_malloc(s->codebook_size);
     if (!s->codebook)
-        goto fail;
+        return AVERROR(ENOMEM);
     s->next_codebook_buffer = av_malloc(s->codebook_size);
     if (!s->next_codebook_buffer)
-        goto fail;
+        return AVERROR(ENOMEM);
 
     /* allocate decode buffer */
     s->decode_buffer_size = (s->width / s->vector_width) *
         (s->height / s->vector_height) * 2;
     s->decode_buffer = av_mallocz(s->decode_buffer_size);
     if (!s->decode_buffer)
-        goto fail;
+        return AVERROR(ENOMEM);
 
     /* initialize the solid-color vectors */
     if (s->vector_height == 4) {
@@ -198,11 +198,6 @@  static av_cold int vqa_decode_init(AVCodecContext *avctx)
     s->next_codebook_buffer_index = 0;
 
     return 0;
-fail:
-    av_freep(&s->codebook);
-    av_freep(&s->next_codebook_buffer);
-    av_freep(&s->decode_buffer);
-    return AVERROR(ENOMEM);
 }
 
 #define CHECK_COUNT() \
@@ -653,5 +648,5 @@  AVCodec ff_vqa_decoder = {
     .decode         = vqa_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
     .defaults       = vqa_defaults,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
 };