[FFmpeg-devel] [PATCH] lavc/srtdec: handle leading whitespace before tag names

wm4 nfxjfg at googlemail.com
Wed Jul 15 14:44:02 CEST 2015


On Tue, 14 Jul 2015 19:10:22 -0500
Rodger Combs <rodger.combs at gmail.com> wrote:

> This fixes cases like `</ font>`.
> 
> I'm not particularly happy with this solution, but anything better would need
> to be part of a larger cleanup.
> ---
>  libavcodec/srtdec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
> index ed3af95..0d1b80e 100644
> --- a/libavcodec/srtdec.c
> +++ b/libavcodec/srtdec.c
> @@ -114,7 +114,9 @@ static void srt_to_ass(AVCodecContext *avctx, AVBPrint *dst,
>          case '<':
>              tag_close = in[1] == '/';
>              len = 0;
> -            if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
> +            while (*(in + 1 + tag_close) == ' ')
> +                in++;
> +            if (sscanf(in + 1 + tag_close, "%127[^>]>%n", buffer, &len) >= 1 && len > 0) {
>                  if ((param = strchr(buffer, ' ')))
>                      *param++ = 0;
>                  if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) ||

If the in variable can be changed without anything breaking, this looks
ok.


More information about the ffmpeg-devel mailing list