diff mbox series

[FFmpeg-devel,03/10] avformat/nutenc: Add goto fail in nut_write_headers()

Message ID 20200504182250.26141-3-andreas.rheinhardt@gmail.com
State Accepted
Commit 9b9a61ca77c65c0dbc71a94cc80aac0f4453999b
Headers show
Series [FFmpeg-devel,01/10] libavformat/nutenc: Remove redundant function parameter
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 4, 2020, 6:22 p.m. UTC
It allows to combine several ffio_free_dyn_buf().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/nutenc.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Michael Niedermayer May 5, 2020, 1:41 p.m. UTC | #1
On Mon, May 04, 2020 at 08:22:43PM +0200, Andreas Rheinhardt wrote:
> It allows to combine several ffio_free_dyn_buf().

LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 6125429cc3..c1606651fe 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -632,8 +632,7 @@  static int write_headers(AVFormatContext *avctx, AVIOContext *bc)
     for (i = 0; i < nut->avf->nb_streams; i++) {
         ret = write_streamheader(avctx, dyn_bc, nut->avf->streams[i], i);
         if (ret < 0) {
-            ffio_free_dyn_buf(&dyn_bc);
-            return ret;
+            goto fail;
         }
         put_packet(nut, bc, dyn_bc, STREAM_STARTCODE);
     }
@@ -646,16 +645,14 @@  static int write_headers(AVFormatContext *avctx, AVIOContext *bc)
         if (ret > 0)
             put_packet(nut, bc, dyn_bc, INFO_STARTCODE);
         else if (ret < 0) {
-            ffio_free_dyn_buf(&dyn_bc);
-                return ret;
+            goto fail;
         }
     }
 
     for (i = 0; i < nut->avf->nb_chapters; i++) {
         ret = write_chapter(nut, dyn_bc, i);
         if (ret < 0) {
-            ffio_free_dyn_buf(&dyn_bc);
-            return ret;
+            goto fail;
         }
         put_packet(nut, bc, dyn_bc, INFO_STARTCODE);
     }
@@ -663,9 +660,11 @@  static int write_headers(AVFormatContext *avctx, AVIOContext *bc)
     nut->last_syncpoint_pos = INT_MIN;
     nut->header_count++;
 
+    ret = 0;
+fail:
     ffio_free_dyn_buf(&dyn_bc);
 
-    return 0;
+    return ret;
 }
 
 static int nut_write_header(AVFormatContext *s)