[FFmpeg-devel] [PATCH 1/3] avformat/segment: Check write_header return value immediately

sebechlebskyjan at gmail.com sebechlebskyjan at gmail.com
Mon Jun 20 17:24:05 CEST 2016


From: Jan Sebechlebsky <sebechlebskyjan at gmail.com>

Check write_header return value immediately after call,
so in the successive statements we can assume the write_header
was successful.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
---
 This is needed for the next patch in patchset.

 libavformat/segment.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index df6f4b5..7e4e840 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -754,6 +754,11 @@ static int seg_init(AVFormatContext *s)
 
     av_dict_copy(&options, seg->format_options, 0);
     ret = avformat_write_header(oc, &options);
+    if (ret < 0) {
+        ff_format_io_close(oc, &oc->pb);
+        goto fail;
+    }
+
     if (av_dict_count(options)) {
         av_log(s, AV_LOG_ERROR,
                "Some of the provided format options in '%s' are not recognized\n", seg->format_options_str);
@@ -761,10 +766,6 @@ static int seg_init(AVFormatContext *s)
         goto fail;
     }
 
-    if (ret < 0) {
-        ff_format_io_close(oc, &oc->pb);
-        goto fail;
-    }
     seg->segment_frame_count = 0;
 
     av_assert0(s->nb_streams == oc->nb_streams);
-- 
1.9.1



More information about the ffmpeg-devel mailing list