From c5f5039b2c950b5bb630e76d42103dd8c679f274 Mon Sep 17 00:00:00 2001 From: Jean-Paul Saman Date: Wed, 19 Jan 2011 16:11:49 +0100 Subject: [PATCH] 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.) --- modules/stream_filter/httplive.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/stream_filter/httplive.c b/modules/stream_filter/httplive.c index 792080fb33..641856b71d 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); -- 2.39.5