aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharlie Monroe <charlie@charliemonroe.net>2021-12-10 11:20:18 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-11 17:15:38 +0100
commit34aee50a7f5a4b36f9f7daf827422d345c7868ed (patch)
tree181849407dfd47d484593c0a21bfd804cf2e6936
parent41b077762cda61a6975dabee9f58444815794619 (diff)
downloadffmpeg-34aee50a7f5a4b36f9f7daf827422d345c7868ed.tar.gz
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>
-rw-r--r--libavcodec/movtextenc.c6
1 files 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;
}