diff mbox

[FFmpeg-devel,2/8] avformat/dashenc: check for null context to avoid uninitialized pointer access

Message ID 1522386498-16238-1-git-send-email-vdixit@akamai.com
State New
Headers show

Commit Message

Dixit, Vishwanath March 30, 2018, 5:08 a.m. UTC
From: Vishwanath Dixit <vdixit@akamai.com>

---
 libavformat/dashenc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index bdf8c8d..c0fe0a5 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -254,7 +254,9 @@  static int flush_dynbuf(OutputStream *os, int *range_length)
     // write out to file
     *range_length = avio_close_dyn_buf(os->ctx->pb, &buffer);
     os->ctx->pb = NULL;
-    avio_write(os->out, buffer + os->written_len, *range_length - os->written_len);
+    if (os->out)
+        avio_write(os->out, buffer + os->written_len,
+                   *range_length - os->written_len);
     os->written_len = 0;
     av_free(buffer);
 
@@ -1358,9 +1360,11 @@  static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
             write_styp(os->ctx->pb);
         avio_flush(os->ctx->pb);
         len = avio_get_dyn_buf (os->ctx->pb, &buf);
-        avio_write(os->out, buf + os->written_len, len - os->written_len);
+        if (os->out) {
+            avio_write(os->out, buf + os->written_len, len - os->written_len);
+            avio_flush(os->out);
+        }
         os->written_len = len;
-        avio_flush(os->out);
     }
 
     return ret;