From 34aee50a7f5a4b36f9f7daf827422d345c7868ed Mon Sep 17 00:00:00 2001 From: Charlie Monroe Date: Fri, 10 Dec 2021 11:20:18 +0100 Subject: [PATCH] avcodec/movtextenc: Check for existence of font name before using it Fixes crashes if the font name is NULL (which it is if a \fn tag is not followed by a font name). Signed-off-by: Charlie Monroe Signed-off-by: Andreas Rheinhardt --- libavcodec/movtextenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 5869942ec0..221cd76fea 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -494,8 +494,10 @@ static void mov_text_alpha_cb(void *priv, int alpha, int alpha_id) static uint16_t find_font_id(MovTextContext *s, const char *name) { - int i; - for (i = 0; i < s->font_count; i++) { + if (!name) + return 1; + + for (int i = 0; i < s->font_count; i++) { if (!strcmp(name, s->fonts[i])) return i + 1; }