[MPlayer-cvslog] CVS: main subreader.c,1.141,1.142

Jindrich Makovicka CVS syncmail at mplayerhq.hu
Mon May 9 20:28:44 CEST 2005


CVS change done by Jindrich Makovicka CVS

Update of /cvsroot/mplayer/main
In directory mail:/var2/tmp/cvs-serv8696

Modified Files:
	subreader.c 
Log Message:
strdup() of a NULL pointer, truckload of cola for me

Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -r1.141 -r1.142
--- subreader.c	4 Feb 2005 18:31:03 -0000	1.141
+++ subreader.c	9 May 2005 18:28:41 -0000	1.142
@@ -1323,11 +1323,16 @@
     mp_msg(MSGT_SUBREADER, MSGL_V, "\n");
     
     for (i = 0; i < langcnt; i++) {
+	char *tmp;
+	
 	if (strcasecmp(languages[i], preferred_language) != 0) continue;
 	analyser = enca_analyser_alloc(languages[i]);
 	encoding = enca_analyse_const(analyser, buffer, buflen);
-	mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detected charset: %s\n", enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV));
-	detected_sub_cp = strdup(enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV));
+	tmp = enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV);
+	if (tmp) {
+	    detected_sub_cp = strdup(tmp);
+	    mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detected charset: %s\n", tmp);
+	}
 	enca_analyser_free(analyser);
     }
     
@@ -1335,7 +1340,10 @@
     free(buffer);
     rewind(fd);
 
-    if (!detected_sub_cp) detected_sub_cp = strdup(fallback);
+    if (!detected_sub_cp) {
+	detected_sub_cp = strdup(fallback);
+	mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detection failed: fallback to %s\n", fallback);
+    }
 
     return detected_sub_cp;
 }




More information about the MPlayer-cvslog mailing list