[MPlayer-dev-eng] Re: [PATCH] Incomplete patch for USF (correct diff) NOVIRUS

Moritz Bunkus moritz at bunkus.org
Wed Dec 10 09:27:54 CET 2003


+	if (!sscanf(line, " <subtitle start=\"%d:%d:%d.%d\" stop=\"%d:%d:%d.%d\"", &a1, &a2, &a3, &a4, &b1, &b2, &b3, &b4)) {

sscanf returns the number of items assigned, so you should better test
for 'sscanf(...) != 8'.

+		printf("SUB: SORRY! USF decoding doesn't parse XML correctly.\n"); //TODO: allow more than one line per time marker

Please use the mp_msg() function for such messages. Never use printf.

+	while (!(p = strstr(line, "<text"))) {
+		fgets(line, LINE_LEN, fd);
+	}

If the subtitle file is broken then this will lead to an endless
loop. You should check fgets' return value.

+	p = &line[0];
+	int len = 0;
+	// detects </text
+	for (;!(*p=='t' && *p-1=='x' && *p-2=='e' && *p-3=='t' && *p-4=='/' && *p-5=='<') && *p; p++,len++); //TODO: allow more than one line per subtitle

1) * (dereference) has precedence over - (subtraction), so *p-1 is
(*p) - 1. This is not what you want.
2) If you want *(p-1), then you're accessing memory that you're not
supposed to access! p is set to &line[0] at the start and you just
access *(p - 5)...


If Darl McBride was in charge, he'd probably make marriage
unconstitutional too, since clearly it de-emphasizes the commercial
nature of normal human interaction, and probably is a major impediment
to the commercial growth of prostitution. - Linus Torvalds
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20031210/9d118618/attachment.pgp>

More information about the MPlayer-dev-eng mailing list