From: Vishwanath Dixit <vdi...@akamai.com>

---
 libavformat/dashenc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index c0fe0a5..4c8fc6f 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -143,6 +143,8 @@ static int dashenc_io_open(AVFormatContext *s, AVIOContext 
**pb, char *filename,
         URLContext *http_url_context = ffio_geturlcontext(*pb);
         av_assert0(http_url_context);
         err = ff_http_do_new_request(http_url_context, filename);
+        if (err < 0)
+            ff_format_io_close(s, pb);
 #endif
     }
     return err;
@@ -152,6 +154,11 @@ static void dashenc_io_close(AVFormatContext *s, 
AVIOContext **pb, char *filenam
     DASHContext *c = s->priv_data;
     int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
 
+    if (!*pb) {
+        av_log(s, AV_LOG_WARNING, "NULL AVIOContext\n");
+        return;
+    }
+
     if (!http_base_proto || !c->http_persistent) {
         ff_format_io_close(s, pb);
 #if CONFIG_HTTP_PROTOCOL
@@ -411,7 +418,12 @@ static void output_segment_list(OutputStream *os, 
AVIOContext *out, AVFormatCont
         snprintf(temp_filename_hls, sizeof(temp_filename_hls), use_rename ? 
"%s.tmp" : "%s", filename_hls);
 
         set_http_options(&http_opts, c);
-        dashenc_io_open(s, &c->m3u8_out, temp_filename_hls, &http_opts);
+        ret = dashenc_io_open(s, &c->m3u8_out, temp_filename_hls, &http_opts);
+        if (ret < 0) {
+            av_log(s, AV_LOG_ERROR, "Unable to open %s for writing %d\n",
+                   temp_filename_hls, ret);
+            return;
+        }
         av_dict_free(&http_opts);
         for (i = start_index; i < os->nb_segments; i++) {
             Segment *seg = os->segments[i];
-- 
1.9.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to