[FFmpeg-devel] [PATCH] Fix comparing NULL string when processing certain subtitle files.

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Dec 10 14:41:56 EET 2021


Charlie Monroe:
> Hi,
> 
> I hope I'm submitting this fix correctly - some subtitles will cause FFmpeg to 
> crash when searching for a font in movtextencode. One such subtitles file is 
> appended. The crash occurrs in find_font_id where the name argument passed is NULL.
> 
> Here is an example command for reproducing the issue:
> 
> ffmpeg -i test.mp4 -i test.ass -c:v copy -c:a copy -c:s 'mov_text' out.mp4
> 
> Cheers,
> 
> Charlie
> 
> 
> 
> Signed-off-by: Charlie Monroe <charlie at charliemonroe.net>
> ---
> libavcodec/movtextenc.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
> index 5869942ec0..df3a2dd97a 100644
> --- a/libavcodec/movtextenc.c
> +++ b/libavcodec/movtextenc.c
> @@ -494,6 +494,9 @@ static void mov_text_alpha_cb(void *priv, int alpha, int 
> alpha_id)
> 
> static uint16_t find_font_id(MovTextContext *s, const char *name)
> {
> +    if (name == NULL)
> +        return 1;
> +
>     int i;
>     for (i = 0; i < s->font_count; i++) {
>         if (!strcmp(name, s->fonts[i]))
> -- 
> 2.30.1 (Apple Git-130)
> 

Thanks for this patch. I will apply this (with the
declaration-after-statement issue fixed) tomorrow unless someone objects
to it or beats me to it.

- Andreas


More information about the ffmpeg-devel mailing list