changeset 869:e350849ff400

Url given without a filename/path get the filename/path '/'
author bertrand
date Fri, 25 May 2001 13:57:18 +0000
parents 5999c2c91500
children f641c96e431b
files url.c
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/url.c	Fri May 25 06:12:37 2001 +0000
+++ b/url.c	Fri May 25 13:57:18 2001 +0000
@@ -78,13 +78,23 @@
 		// 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;