[vlc-commits] commit: make_URI: fix assertion failures (fix #3956) ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Fri Jul 30 08:44:00 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jul 30 09:41:32 2010 +0300| [615bcffe5297b99422ffec435228ac015ae12d64] | committer: Rémi Denis-Courmont 

make_URI: fix assertion failures (fix #3956)

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.

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

 src/test/url.c     |    1 +
 src/text/strings.c |   10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/test/url.c b/src/test/url.c
index 4dcb0d4..2084986 100644
--- a/src/test/url.c
+++ b/src/test/url.c
@@ -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);*/
diff --git a/src/text/strings.c b/src/text/strings.c
index fa1b39c..a53907d 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -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)



More information about the vlc-commits mailing list