]> git.sesse.net Git - vlc/commitdiff
stream_filter/httplive.c: relative_URI() determine base path of p_sys->m3u8.psz_path
authorJean-Paul Saman <jean-paul.saman@m2x.nl>
Wed, 29 Dec 2010 14:41:54 +0000 (15:41 +0100)
committerJean-Paul Saman <jean-paul.saman@m2x.nl>
Wed, 29 Dec 2010 15:49:20 +0000 (16:49 +0100)
commit-id: 61042012fa846988d7d7c364396478850afedf67 simplified relative_URI()
a bit too much.

modules/stream_filter/httplive.c

index f875854fea534252f71af7d1d358330c0c58bd61..2242f6f570b4b34ff6018aeabf3d76ca0ae4834f 100644 (file)
@@ -347,22 +347,30 @@ static char *relative_URI(stream_t *s, const char *uri, const char *path)
     if (p != NULL)
         return NULL;
 
+    char *psz_path = strdup(p_sys->m3u8.psz_path);
+    if (psz_path == NULL) return NULL;
+    p = strrchr(psz_path, '/');
+    if (p) *p = '\0';
+
     char *psz_uri = NULL;
     if (p_sys->m3u8.psz_password || p_sys->m3u8.psz_username)
     {
         if (asprintf(&psz_uri, "%s://%s:%s@%s%s/%s", p_sys->m3u8.psz_protocol,
                      p_sys->m3u8.psz_username, p_sys->m3u8.psz_password,
-                     p_sys->m3u8.psz_host,
-                     path ? path : p_sys->m3u8.psz_path, uri) < 0)
-            return NULL;
+                     p_sys->m3u8.psz_host, path ? path : psz_path, uri) < 0)
+            goto fail;
     }
     else
     {
         if (asprintf(&psz_uri, "%s://%s%s/%s", p_sys->m3u8.psz_protocol,
-                 p_sys->m3u8.psz_host, path ? path : p_sys->m3u8.psz_path, uri) < 0)
-           return NULL;
+                 p_sys->m3u8.psz_host, path ? path : psz_path, uri) < 0)
+           goto fail;
     }
     return psz_uri;
+
+fail:
+    free(psz_path);
+    return NULL;
 }
 
 static void parse_SegmentInformation(stream_t *s, hls_stream_t *hls, char *p_read, char *uri)
@@ -1270,8 +1278,6 @@ static int Open(vlc_object_t *p_this)
         free(p_sys);
         return VLC_ENOMEM;
     }
-    char *psz_path = strrchr(psz_uri, '/');
-    if (psz_path) *psz_path = '\0';
     vlc_UrlParse(&p_sys->m3u8, psz_uri, 0);
     free(psz_uri);