summaryrefslogtreecommitdiffstats
path: root/url.c
diff options
context:
space:
mode:
authorbertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-25 13:57:18 +0000
committerbertrand <bertrand@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-25 13:57:18 +0000
commit89ef6acd52ae4cf1696a196ed6b699656432839f (patch)
tree92f9384d1ac7fff883d288b7017e222554f59bc3 /url.c
parente983def74925ff3cb59cf0924b0a83b01e2bfffa (diff)
downloadmpv-89ef6acd52ae4cf1696a196ed6b699656432839f.tar.bz2
mpv-89ef6acd52ae4cf1696a196ed6b699656432839f.tar.xz
Url given without a filename/path get the filename/path '/'
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@870 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'url.c')
-rw-r--r--url.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/url.c b/url.c
index 5f3b52100a..97e6b566ce 100644
--- a/url.c
+++ b/url.c
@@ -78,13 +78,23 @@ set_url(char* url) {
// check if it's not a trailing '/'
if( strlen(ptr2)>1 ) {
// copy the path/filename in the URL container
- Curl->file = (char*)malloc(strlen(ptr2));
+ Curl->file = (char*)malloc(strlen(ptr2)+1);
if( Curl->file==NULL ) {
printf("Memory allocation failed!\n");
exit(1);
}
- strcpy(Curl->file, ptr2+1);
+ Curl->file[0]='/';
+ strcpy(Curl->file+1, ptr2+1);
}
+ }
+ // Check if a filenme was given or set else set it with '/'
+ if( Curl->file==NULL ) {
+ Curl->file = (char*)malloc(2);
+ if( Curl->file==NULL ) {
+ printf("Memory allocation failed!\n");
+ exit(1);
+ }
+ strcpy(Curl->file, "/");
}
return Curl;