From: RĂ©mi Denis-Courmont Date: Fri, 30 Jul 2010 06:41:32 +0000 (+0300) Subject: make_URI: fix assertion failures (fix #3956) X-Git-Tag: 1.2.0-pre1~5612 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=615bcffe5297b99422ffec435228ac015ae12d64;p=vlc 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. --- diff --git a/src/test/url.c b/src/test/url.c index 4dcb0d40cc..2084986630 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 fa1b39cfe0..a53907d655 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)