[Mplayer-cvslog] CVS: main subreader.c,1.126,1.127

Attila Kinali CVS attila at mplayerhq.hu
Sat Jan 24 13:54:08 CET 2004


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

Modified Files:
	subreader.c 
Log Message:
prevent subreader from segfaulting when sami subs dont have
a <P> at the beginning.
patch by Fabien Tassin <fta+mplayer at sofaraway.org>


Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -r1.126 -r1.127
--- subreader.c	19 Nov 2003 01:41:27 -0000	1.126
+++ subreader.c	24 Jan 2004 12:54:05 -0000	1.127
@@ -113,13 +113,24 @@
 	    s = stristr (s, "Start=");
 	    if (s) {
 		current->start = strtol (s + 6, &s, 0) / 10;
+                /* eat '>' */
+                for (; *s != '>' && *s != '\0'; s++);
+                s++;
 		state = 1; continue;
 	    }
 	    break;
  
-	case 1: /* find "<P" */
-	    if ((s = stristr (s, "<P"))) { s += 2; state = 2; continue; }
-	    break;
+	case 1: /* find (optionnal) "<P", skip other TAGs */
+	    for  (; *s == ' ' || *s == '\t'; s++); /* strip blanks, if any */
+	    if (*s == '\0') break;
+	    if (*s != '<') { state = 3; p = text; continue; } /* not a TAG */
+	    s++;
+	    if (*s == 'P' || *s == 'p') { s++; state = 2; continue; } /* found '<P' */
+	    for (; *s != '>' && *s != '\0'; s++); /* skip remains of non-<P> TAG */
+	    if (s == '\0')
+	      break;
+	    s++;
+	    continue;
  
 	case 2: /* find ">" */
 	    if ((s = strchr (s, '>'))) { s++; state = 3; p = text; continue; }




More information about the MPlayer-cvslog mailing list