[MPlayer-cvslog] r37213 - trunk/sub/subreader.c

reimar subversion at mplayerhq.hu
Tue May 27 21:22:12 CEST 2014


Author: reimar
Date: Tue May 27 21:22:12 2014
New Revision: 37213

Log:
subreader: Check the %n result variable.

This ensures we had an actual match against the
full string.
Ideally this would be possible by checking for a one larger
return value, but unfortunately the standard is unclear if
%n arguments should be counted or not...

Modified:
   trunk/sub/subreader.c

Modified: trunk/sub/subreader.c
==============================================================================
--- trunk/sub/subreader.c	Tue May 27 21:22:11 2014	(r37212)
+++ trunk/sub/subreader.c	Tue May 27 21:22:12 2014	(r37213)
@@ -607,44 +607,54 @@ static subtitle *sub_read_line_rt(stream
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d.%d\" %*[Ee]nd=\"%d.%d\"%*[^<]<clear/>%n",&a3,&a4,&b3,&b4,&plen) >= 4;
+		match &= plen > 0;
 	}
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d.%d\" %*[Ee]nd=\"%d:%d.%d\"%*[^<]<clear/>%n",&a3,&a4,&b2,&b3,&b4,&plen) >= 5;
+		match &= plen > 0;
 	}
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d:%d\" %*[Ee]nd=\"%d:%d\"%*[^<]<clear/>%n",&a2,&a3,&b2,&b3,&plen) >= 4;
+		match &= plen > 0;
 	}
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d:%d\" %*[Ee]nd=\"%d:%d.%d\"%*[^<]<clear/>%n",&a2,&a3,&b2,&b3,&b4,&plen) >= 5;
+		match &= plen > 0;
 	}
 //	sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d:%d.%d\" %*[Ee]nd=\"%d:%d\"%*[^<]<clear/>%n",&a2,&a3,&a4,&b2,&b3,&plen) >= 5
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d:%d.%d\" %*[Ee]nd=\"%d:%d.%d\"%*[^<]<clear/>%n",&a2,&a3,&a4,&b2,&b3,&b4,&plen) >= 6;
+		match &= plen > 0;
 	}
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d:%d:%d.%d\" %*[Ee]nd=\"%d:%d:%d.%d\"%*[^<]<clear/>%n",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4,&plen) >= 8;
+		match &= plen > 0;
 	}
 	//now try it without end time
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d.%d\"%*[^<]<clear/>%n",&a3,&a4,&plen) >= 2;
+		match &= plen > 0;
 	}
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d:%d\"%*[^<]<clear/>%n",&a2,&a3,&plen) >= 2;
+		match &= plen > 0;
 	}
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d:%d.%d\"%*[^<]<clear/>%n",&a2,&a3,&a4,&plen) >= 3;
+		match &= plen > 0;
 	}
 	if (!match) {
 		plen=a1=a2=a3=a4=b1=b2=b3=b4=0;
 		match = sscanf(line, "<%*[tT]ime %*[bB]egin=\"%d:%d:%d.%d\"%*[^<]<clear/>%n",&a1,&a2,&a3,&a4,&plen) >= 4;
+		match &= plen > 0;
 	}
 	if (!match)
 	    continue;


More information about the MPlayer-cvslog mailing list