]> git.sesse.net Git - vlc/commitdiff
make_URI: fix assertion failures (fix #3956)
authorRémi Denis-Courmont <remi@remlab.net>
Fri, 30 Jul 2010 06:41:32 +0000 (09:41 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 30 Jul 2010 06:42:40 +0000 (09:42 +0300)
Handles "\\hostname" properly.
On Windows, error out on "X:directory" instead of aborting. Looking up
the current directory of the specified drive letter would be a better,
though.

src/test/url.c
src/text/strings.c

index 4dcb0d40cc25eed611981706493259925d09e5c2..20849866305616cb146fc9540fde642b2f43a182 100644 (file)
@@ -127,6 +127,7 @@ int main (void)
     test_path ("/home/john/music.ogg", "file:///home/john/music.ogg");
     test_path ("\\\\server/pub/music.ogg", "smb://server/pub/music.ogg");
     test_path ("\\\\server\\pub\\music.ogg", "smb://server/pub/music.ogg");
+    test_path ("\\\\server", "smb://server");
 
     /*int fd = open (".", O_RDONLY);
     assert (fd != -1);*/
index fa1b39cfe05eadc81c708c39f5147f58767dec57..a53907d655bed735590cf297fd8620590f321cfb 100644 (file)
@@ -1048,11 +1048,16 @@ char *make_URI (const char *path, const char *scheme)
 
     char *buf;
 #ifdef WIN32
+    /* Drive letter */
     if (isalpha (path[0]) && (path[1] == ':'))
     {
-        if (asprintf (&buf, "%s:///%c:", scheme ? scheme : "file", path[0]) == -1)
+        if (asprintf (&buf, "%s:///%c:", scheme ? scheme : "file",
+                      path[0]) == -1)
             buf = NULL;
         path += 2;
+# warning Drive letter-relative path not implemented!
+        if (path[0] != DIR_SEP_CHAR)
+            return NULL;
     }
     else
 #endif
@@ -1088,6 +1093,9 @@ char *make_URI (const char *path, const char *scheme)
             snprintf (buf, sizeof (SMB_SCHEME) + 3 + hostlen,
                       SMB_SCHEME"://%s", path + 2);
         path += 2 + hostlen;
+
+        if (path[0] == '\0')
+            return buf; /* Hostname without path */
     }
     else
     if (path[0] != DIR_SEP_CHAR)