diff options
author | attila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-01-24 12:54:05 +0000 |
---|---|---|
committer | attila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-01-24 12:54:05 +0000 |
commit | ab424093b42f2fdc54a991eecd009eaef45f5360 (patch) | |
tree | 760f150255f9ff04e613314dc014ce4732d4d6d7 /subreader.c | |
parent | a4ac1dc9a422ccc5ed92b519758f68acc3b75e9a (diff) | |
download | mpv-ab424093b42f2fdc54a991eecd009eaef45f5360.tar.bz2 mpv-ab424093b42f2fdc54a991eecd009eaef45f5360.tar.xz |
prevent subreader from segfaulting when sami subs dont have
a <P> at the beginning.
patch by Fabien Tassin <fta+mplayer@sofaraway.org>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11839 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subreader.c')
-rw-r--r-- | subreader.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/subreader.c b/subreader.c index f11fce6fbe..078b53f228 100644 --- a/subreader.c +++ b/subreader.c @@ -113,13 +113,24 @@ subtitle *sub_read_line_sami(FILE *fd, subtitle *current) { 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; } |