changeset 7809:72a156e6d482

Fixed more potential mem leaks and use the url_free method to free all the member pointers of the url.
author bertrand
date Sat, 19 Oct 2002 23:28:51 +0000
parents 502f6eff2c1a
children 37ae6cfc7cf2
files libmpdemux/url.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/url.c	Sat Oct 19 22:06:46 2002 +0000
+++ b/libmpdemux/url.c	Sat Oct 19 23:28:51 2002 +0000
@@ -33,7 +33,7 @@
 	Curl->url = strdup(url);
 	if( Curl->url==NULL ) {
 		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n");
-		free(Curl);
+		url_free(Curl);
 		return NULL;
 	}
 
@@ -41,7 +41,7 @@
 	ptr1 = strstr(url, "://");
 	if( ptr1==NULL ) {
 		mp_msg(MSGT_NETWORK,MSGL_V,"Not an URL!\n");
-		free(Curl->url);free(Curl);
+		url_free(Curl);
 		return NULL;
 	}
 	pos1 = ptr1-url;
@@ -49,7 +49,7 @@
 	strncpy(Curl->protocol, url, pos1);
 	if( Curl->protocol==NULL ) {
 		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n");
-		free(Curl->protocol);free(Curl->url);free(Curl);
+		url_free(Curl);
 		return NULL;
 	}
 	Curl->protocol[pos1] = '\0';
@@ -71,6 +71,7 @@
 		Curl->username = (char*)malloc(len+1);
 		if( Curl->username==NULL ) {
 			mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n");
+			url_free(Curl);
 			return NULL;
 		}
 		strncpy(Curl->username, ptr1, len);
@@ -84,6 +85,7 @@
 			Curl->password = (char*)malloc(len2+1);
 			if( Curl->password==NULL ) {
 				mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n");
+				url_free(Curl);
 				return NULL;
 			}
 			strncpy( Curl->password, ptr3+1, len2);
@@ -120,6 +122,7 @@
 	Curl->hostname = (char*)malloc(pos2-pos1+1);
 	if( Curl->hostname==NULL ) {
 		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n");
+		url_free(Curl);
 		return NULL;
 	}
 	strncpy(Curl->hostname, ptr1, pos2-pos1);
@@ -135,6 +138,7 @@
 			Curl->file = strdup(ptr2);
 			if( Curl->file==NULL ) {
 				mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n");
+				url_free(Curl);
 				return NULL;
 			}
 		}
@@ -144,6 +148,7 @@
 		Curl->file = (char*)malloc(2);
 		if( Curl->file==NULL ) {
 			mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n");
+			url_free(Curl);
 			return NULL;
 		}
 		strcpy(Curl->file, "/");