diff mbox series

[FFmpeg-devel,v3,8/8] avcodec/movtextenc: Cleanup generically on init failure

Message ID 20201017073745.403153-8-andreas.rheinhardt@gmail.com
State Accepted
Commit 21346672270ae723aa774a9c8b0749954a75b3df
Headers show
Series [FFmpeg-devel,v3,1/8] avcodec/movtextenc: Fix potential use of uninitialized value | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/PPC64_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make_fate warning Make fate failed

Commit Message

Andreas Rheinhardt Oct. 17, 2020, 7:37 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/movtextenc.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 2082dc9b25..1bef21e0b9 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -30,6 +30,7 @@ 
 #include "ass_split.h"
 #include "ass.h"
 #include "bytestream.h"
+#include "internal.h"
 
 #define STYLE_FLAG_BOLD         (1<<0)
 #define STYLE_FLAG_ITALIC       (1<<1)
@@ -331,19 +332,13 @@  static av_cold int mov_text_encode_init(AVCodecContext *avctx)
     av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED);
 
     s->ass_ctx = ff_ass_split(avctx->subtitle_header);
-    if (!s->ass_ctx) {
-        ret = AVERROR_INVALIDDATA;
-        goto fail;
-    }
+    if (!s->ass_ctx)
+        return AVERROR_INVALIDDATA;
     ret = encode_sample_description(avctx);
     if (ret < 0)
-        goto fail;
+        return ret;
 
     return 0;
-
-fail:
-    mov_text_encode_close(avctx);
-    return ret;
 }
 
 // Start a new style box if needed
@@ -736,4 +731,5 @@  AVCodec ff_movtext_encoder = {
     .init           = mov_text_encode_init,
     .encode_sub     = mov_text_encode_frame,
     .close          = mov_text_encode_close,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };