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 <charlie@charliemonroe.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Charlie Monroe 2021-12-10 11:20:18 +01:00 committed by Andreas Rheinhardt
parent 41b077762c
commit 34aee50a7f
1 changed files with 4 additions and 2 deletions

View File

@ -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;
}