[Mplayer-cvslog] CVS: main/libmpdemux tv.c,1.47,1.48

Arpi of Ize arpi at mplayerhq.hu
Wed Jan 15 00:15:54 CET 2003


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

Modified Files:
	tv.c 
Log Message:
sanity checks - patch by Fabian Franz <FabianFranz at gmx.de>
cache results of strchr() calls


Index: tv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- tv.c	6 Jan 2003 13:12:09 -0000	1.47
+++ tv.c	14 Jan 2003 23:15:36 -0000	1.48
@@ -245,15 +245,18 @@
 
 	while (*tv_param_channels) {
 		char* tmp = *(tv_param_channels++);
+		char* sep = strchr(tmp,'-');
 		int i;
 		struct CHANLIST cl;
 
-		strcpy(tv_channel_current->name, strchr(tmp, '-') + 1);
-		strchr(tmp, '-')[0] = '\0';
+		if (!sep) continue; // Wrong syntax, but mplayer should not crash
+
+		strcpy(tv_channel_current->name, sep + 1);
+		sep[0] = '\0';
 		strncpy(tv_channel_current->number, tmp, 5);
 
-		while (strchr(tv_channel_current->name, '_'))
-			strchr(tv_channel_current->name, '_')[0] = ' ';
+		while ((sep=strchr(tv_channel_current->name, '_')))
+		    sep[0] = ' ';
 
 		tv_channel_current->freq = 0;
 		for (i = 0; i < chanlists[tvh->chanlist].count; i++) {
@@ -277,8 +280,8 @@
 		tv_channel_current->next->next = NULL;
 		tv_channel_current = tv_channel_current->next;
 	}
-
-	tv_channel_current->prev->next = NULL;
+	if (tv_channel_current->prev)
+  	  tv_channel_current->prev->next = NULL;
 	free(tv_channel_current);
     } else 
 	    tv_channel_last_real = malloc(sizeof(char)*5);



More information about the MPlayer-cvslog mailing list