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

vdixit at akamai.com vdixit at akamai.com
Fri Mar 30 08:08:18 EEST 2018


From: Vishwanath Dixit <vdixit at akamai.com>

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

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;
-- 
1.9.1



More information about the ffmpeg-devel mailing list