diff mbox series

[FFmpeg-devel,4/5] avformat/fifo: close IO in case header writing fails

Message ID 20201207100845.17520-5-jeebjp@gmail.com
State New
Headers show
Series FIFO meta muxer related improvements | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Jan Ekström Dec. 7, 2020, 10:08 a.m. UTC
From: Jan Ekström <jan.ekstrom@24i.com>

Otherwise each new attempt will leave its connection open.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
 libavformat/fifo.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index 9fc524adbdf..bc363e458cd 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -142,8 +142,14 @@  static int fifo_thread_write_header(FifoThreadContext *ctx)
         avf2->streams[i]->cur_dts = 0;
 
     ret = avformat_write_header(avf2, &format_options);
-    if (!ret)
-        ctx->header_written = 1;
+    if (ret < 0) {
+        av_log(avf2, AV_LOG_ERROR,
+               "Failed to write format header: %s\n", av_err2str(ret));
+        ff_format_io_close(avf2, &avf2->pb);
+        goto end;
+    }
+
+    ctx->header_written = 1;
 
     // Check for options unrecognized by underlying muxer
     if (format_options) {