[FFmpeg-cvslog] avformat/hlsenc: fix hls_write_trailer() on hls_start() failure

Christian Suloway git at videolan.org
Tue Dec 16 04:13:16 CET 2014


ffmpeg | branch: master | Christian Suloway <csuloway at row44.com> | Mon Dec 15 18:10:46 2014 -0600| [92a596f13bfa9136a58229f84ef8ec50d63ff536] | committer: Michael Niedermayer

avformat/hlsenc: fix hls_write_trailer() on hls_start() failure

Close segment I/O context and append segment in hls_write_trailer() only
when segment I/O context is allocated.

Signed-off-by: Christian Suloway <csuloway at globaleagleent.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=92a596f13bfa9136a58229f84ef8ec50d63ff536
---

 libavformat/hlsenc.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 79f3a23..7645065 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -449,7 +449,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
                 av_opt_set(hls->avf->priv_data, "mpegts_flags", "resend_headers", 0);
             hls->number++;
         } else {
-            avio_close(oc->pb);
+            avio_closep(&oc->pb);
 
             ret = hls_start(s);
         }
@@ -474,10 +474,12 @@ static int hls_write_trailer(struct AVFormatContext *s)
     AVFormatContext *oc = hls->avf;
 
     av_write_trailer(oc);
-    hls->size = avio_tell(hls->avf->pb) - hls->start_pos;
-    avio_closep(&oc->pb);
+    if (oc->pb) {
+        hls->size = avio_tell(hls->avf->pb) - hls->start_pos;
+        avio_closep(&oc->pb);
+        hls_append_segment(hls, hls->duration, hls->start_pos, hls->size);
+    }
     av_free(hls->basename);
-    hls_append_segment(hls, hls->duration, hls->start_pos, hls->size);
     avformat_free_context(oc);
     hls->avf = NULL;
     hls_window(s, 1);



More information about the ffmpeg-cvslog mailing list