[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:47:20 CEST 2010


vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jul 30 09:47:14 2010 +0300| [8a6a55026b6dd95766a0cbdce40ef614c2e749e8] | 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.
(cherry picked from commit 615bcffe5297b99422ffec435228ac015ae12d64)

Conflicts:

	src/text/strings.c

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

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

diff --git a/src/test/url.c b/src/test/url.c
index a5742df..6b79517 100644
--- a/src/test/url.c
+++ b/src/test/url.c
@@ -122,6 +122,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 23391d2..3f287eb 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -1061,11 +1061,15 @@ char *make_URI (const char *path)
 
     char *buf;
 #ifdef WIN32
+    /* Drive letter */
     if (isalpha (path[0]) && (path[1] == ':'))
     {
         if (asprintf (&buf, "file:///%c:", path[0]) == -1)
             buf = NULL;
         path += 2;
+# warning Drive letter-relative path not implemented!
+        if (path[0] != DIR_SEP_CHAR)
+            return NULL;
     }
     else
 #endif
@@ -1098,6 +1102,9 @@ char *make_URI (const char *path)
             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