[vlc-commits] stream_filter/httplive.c: do not crash on strdup(NULL)

Jean-Paul Saman git at videolan.org
Wed Jan 19 16:22:44 CET 2011


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Wed Jan 19 16:11:49 2011 +0100| [c5f5039b2c950b5bb630e76d42103dd8c679f274] | committer: Jean-Paul Saman

stream_filter/httplive.c: do not crash on strdup(NULL)

httplive crashed in parse_SegmentInformation on line 428. The cause is
that hls->url.psz_path can be NULL, when there is no meta playlist involved.
In that situation it results in a crash of vlc. (Issue reported by Felix Kuehne.)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c5f5039b2c950b5bb630e76d42103dd8c679f274
---

 modules/stream_filter/httplive.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c
index 792080f..641856b 100644
--- a/modules/stream_filter/httplive.c
+++ b/modules/stream_filter/httplive.c
@@ -383,6 +383,9 @@ static char *relative_URI(stream_t *s, const char *uri, const char *path)
     if (p != NULL)
         return NULL;
 
+    if (p_sys->m3u8.psz_path == NULL)
+        return NULL;
+
     char *psz_path = strdup(p_sys->m3u8.psz_path);
     if (psz_path == NULL) return NULL;
     p = strrchr(psz_path, '/');
@@ -425,14 +428,18 @@ static void parse_SegmentInformation(stream_t *s, hls_stream_t *hls, char *p_rea
         return;
     }
 
-    char *psz_path = strdup(hls->url.psz_path);
-    if (psz_path == NULL)
+    char *psz_path = NULL;
+    if (hls->url.psz_path != NULL)
     {
-        p_sys->b_error = true;
-        return;
+        char *psz_path = strdup(hls->url.psz_path);
+        if (psz_path == NULL)
+        {
+            p_sys->b_error = true;
+            return;
+        }
+        char *p = strrchr(psz_path, '/');
+        if (p) *p = '\0';
     }
-    char *p = strrchr(psz_path, '/');
-    if (p) *p = '\0';
     char *psz_uri = relative_URI(s, uri, psz_path);
     free(psz_path);
 



More information about the vlc-commits mailing list