mirror of https://git.ffmpeg.org/ffmpeg.git
lavc/srtdec: make some sscanf to work at the end of a line.
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.
This commit is contained in:
parent
c36302a7a4
commit
d927d8395d
|
@ -50,7 +50,7 @@ typedef struct {
|
|||
static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
|
||||
const char *in, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
char c, *param, buffer[128], tmp[128];
|
||||
char *param, buffer[128], tmp[128];
|
||||
int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
|
||||
SrtStack stack[16];
|
||||
|
||||
|
@ -89,16 +89,18 @@ 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) {
|
||||
len = 0;
|
||||
an += sscanf(in, "{\\an%*1u}%n", &len) >= 0 && len > 0;
|
||||
if ((an != 1 && (len = 0, sscanf(in, "{\\%*[^}]}%n", &len) >= 0 && len > 0)) ||
|
||||
(len = 0, sscanf(in, "{%*1[CcFfoPSsYy]:%*[^}]}%n", &len) >= 0 && len > 0)) {
|
||||
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) {
|
||||
len = 0;
|
||||
if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
|
||||
if ((param = strchr(buffer, ' ')))
|
||||
*param++ = 0;
|
||||
if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||
|
||||
|
|
Loading…
Reference in New Issue