[FFmpeg-cvslog] avcodec/movtextenc: Check for existence of font name before using it

Charlie Monroe git at videolan.org
Sat Dec 11 18:29:30 EET 2021


ffmpeg | branch: master | Charlie Monroe <charlie at charliemonroe.net> | Fri Dec 10 11:20:18 2021 +0100| [34aee50a7f5a4b36f9f7daf827422d345c7868ed] | committer: Andreas Rheinhardt

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 at charliemonroe.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=34aee50a7f5a4b36f9f7daf827422d345c7868ed
---

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



More information about the ffmpeg-cvslog mailing list