avformat/hlsenc: fix Explicit null dereferenced in hlsenc
authorSteven Liu <lq@chinaffmpeg.org>
Thu, 5 Jan 2017 22:29:12 +0000 (06:29 +0800)
committerSteven Liu <lq@chinaffmpeg.org>
Thu, 5 Jan 2017 22:29:12 +0000 (06:29 +0800)
CID: 1398228
Passing null pointer dirname to strlen, which dereferences it.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
libavformat/hlsenc.c

index 920987f..eeb450a 100644 (file)
@@ -285,8 +285,8 @@ static int hls_delete_old_segments(HLSContext *hls) {
                                      path, strerror(errno));
         }
 
-        if (segment->sub_filename[0] != '\0') {
-            sub_path_size = strlen(dirname) + strlen(segment->sub_filename) + 1;
+        if ((segment->sub_filename[0] != '\0')) {
+            sub_path_size = strlen(segment->sub_filename) + 1 + (dirname ? strlen(dirname) : 0);
             sub_path = av_malloc(sub_path_size);
             if (!sub_path) {
                 ret = AVERROR(ENOMEM);