[Mplayer-cvslog] CVS: main/libmpdemux demux_viv.c,1.18,1.19 tv.c,1.18,1.19 url.c,1.10,1.11

pl pl at mplayer.dev.hu
Wed Dec 19 14:03:24 CET 2001


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv20857

Modified Files:
	demux_viv.c tv.c url.c 
Log Message:
x = malloc(strlen(s) + c) ... strcpy(x, s)
replaced by
x = strdup(s)

Note: sometimes c was 0 and that was a bug
Note2: code still has to be added to check the returned value of these funcs


Index: demux_viv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_viv.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- demux_viv.c	16 Dec 2001 14:51:04 -0000	1.18
+++ demux_viv.c	19 Dec 2001 13:03:22 -0000	1.19
@@ -191,26 +191,22 @@
 	if (!strcmp(opt, "Title"))
 	{
 	    demux_info_add(demux, "name", param);
-	    priv->title = malloc(strlen(param));
-	    strcpy(priv->title, param);
+	    priv->title = strdup(param);
 	}
 	if (!strcmp(opt, "Author"))
 	{
 	    demux_info_add(demux, "author", param);
-	    priv->author = malloc(strlen(param));
-	    strcpy(priv->author, param);
+	    priv->author = strdup(param);
 	}
 	if (!strcmp(opt, "Copyright"))
 	{
 	    demux_info_add(demux, "copyright", param);
-	    priv->copyright = malloc(strlen(param));
-	    strcpy(priv->copyright, param);
+	    priv->copyright = strdup(param);
 	}
 	if (!strcmp(opt, "Producer"))
 	{
 	    demux_info_add(demux, "encoder", param);
-	    priv->producer = malloc(strlen(param));
-	    strcpy(priv->producer, param);
+	    priv->producer = strdup(param);
 	}
 
 	/* get next token */

Index: tv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- tv.c	9 Dec 2001 15:39:35 -0000	1.18
+++ tv.c	19 Dec 2001 13:03:22 -0000	1.19
@@ -343,8 +343,7 @@
 	mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvh->info->comment);
 
     params = malloc(sizeof(tvi_param_t)*2);
-    params[0].opt = malloc(strlen("input"));
-    sprintf((char *)params[0].opt, "input");
+    params[0].opt = strdup("input");
     params[0].value = malloc(sizeof(int));
     (int)*(void **)params[0].value = tv_param_input;
     params[1].opt = params[1].value = NULL;

Index: url.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/url.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- url.c	14 Dec 2001 23:48:47 -0000	1.10
+++ url.c	19 Dec 2001 13:03:22 -0000	1.11
@@ -29,12 +29,11 @@
 	memset( Curl, 0, sizeof(URL_t) );
 
 	// Copy the url in the URL container
-	Curl->url = (char*)malloc(strlen(url)+1);
+	Curl->url = strdup(url);
 	if( Curl->url==NULL ) {
 		printf("Memory allocation failed!\n");
 		return NULL;
 	}
-	strcpy(Curl->url, url);
 
 	// extract the protocol
 	ptr1 = strstr(url, "://");
@@ -86,12 +85,11 @@
 		// 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)+1);
+			Curl->file = strdup(ptr2);
 			if( Curl->file==NULL ) {
 				printf("Memory allocation failed!\n");
 				return NULL;
 			}
-			strcpy(Curl->file, ptr2);
 		}
 	} 
 	// Check if a filenme was given or set, else set it with '/'




More information about the MPlayer-cvslog mailing list