[MPlayer-dev-eng] [PATCH] SAMI seg fault

Fabien Tassin fta+mplayer at sofaraway.org
Sun Jan 11 21:20:03 CET 2004


Hi,

Current SAMI code expects a <P.*> after "START=" but many subs have
no <P> at all.. leading to a seg fault.
According to MS specs, this seems not required (even if all examples
use <P.*>).
Please consider the attached patch. Tested with both flavors of SAMI subs.

/Fabien
-------------- next part --------------
--- subreader.c.orig	2004-01-11 19:36:57.000000000 +0100
+++ subreader.c	2004-01-11 20:53:32.000000000 +0100
@@ -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-dev-eng mailing list