[FFmpeg-devel] [PATCH 1/2] lavc/srtdec: make some sscanf to work at the end of a line.
Clément Bœsch
ubitux at gmail.com
Sat Dec 29 23:52:09 CET 2012
Fix sscanf calls that can't work at the end of a line unless it ends
with \r\n or \n: the markup line may/should/must not end with these
characters.
---
libavcodec/srtdec.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
index cac4b39..55a6fab 100644
--- a/libavcodec/srtdec.c
+++ b/libavcodec/srtdec.c
@@ -89,16 +89,16 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
break;
case '{': /* skip all {\xxx} substrings except for {\an%d}
and all microdvd like styles such as {Y:xxx} */
- an += sscanf(in, "{\\an%*1u}%c", &c) == 1;
- if ((an != 1 && sscanf(in, "{\\%*[^}]}%n%c", &len, &c) > 0) ||
- sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]}%n%c", &len, &c) > 0) {
+ an += sscanf(in, "{\\an%*1u%c", &c) == 1 && c == '}';
+ if ((an != 1 && sscanf(in, "{\\%*[^}]%c%n", &c, &len) > 0 && c == '}') ||
+ sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]%c%n", &c, &len) > 0 && c == '}') {
in += len - 1;
} else
*out++ = *in;
break;
case '<':
tag_close = in[1] == '/';
- if (sscanf(in+tag_close+1, "%127[^>]>%n%c", buffer, &len,&c) >= 2) {
+ if (sscanf(in+tag_close+1, "%127[^>]%c%n", buffer, &c, &len) >= 2 && c == '>') {
if ((param = strchr(buffer, ' ')))
*param++ = 0;
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
--
1.8.0.3
More information about the ffmpeg-devel
mailing list