[FFmpeg-devel] [PATCH] hls: fix a null pointer dereference

wm4 nfxjfg at googlemail.com
Mon Feb 16 19:31:42 CET 2015


Not allocating the pls->ctx will crash in libavformat/hls.c:1410, where
it tries to dereference the field.

Sample: http://ec24.rtp.pt/liverepeater/rtpn.smil/playlist.m3u8
---
 libavformat/hls.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index f17b826..4fdda34 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1313,14 +1313,14 @@ static int hls_read_header(AVFormatContext *s)
         struct playlist *pls = c->playlists[i];
         AVInputFormat *in_fmt = NULL;
 
-        if (pls->n_segments == 0)
-            continue;
-
         if (!(pls->ctx = avformat_alloc_context())) {
             ret = AVERROR(ENOMEM);
             goto fail;
         }
 
+        if (pls->n_segments == 0)
+            continue;
+
         pls->index  = i;
         pls->needed = 1;
         pls->parent = s;
-- 
2.1.4



More information about the ffmpeg-devel mailing list