]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/movtextenc: Don't presume every style to have a font
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 16 Oct 2020 14:33:23 +0000 (16:33 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 19 Oct 2020 19:37:15 +0000 (21:37 +0200)
Fixes segfaults in the absence of fonts; this can happen because the
file didn't contain any or because the allocation of the font-string
failed.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/movtextenc.c

index 81e8c2e8026bffa26b98a9de49513d0b955ab849..dcdbf16e0859eab053b9cab7e64dea0fd49cfb9a 100644 (file)
@@ -298,10 +298,14 @@ static int encode_sample_description(AVCodecContext *avctx)
     // is avaiable in the ASS header
     if (style && ass->styles_count) {
         // Find unique font names
-        av_dynarray_add(&s->fonts, &s->font_count, style->font_name);
-        font_names_total_len += strlen(style->font_name);
+        if (style->font_name) {
+            av_dynarray_add(&s->fonts, &s->font_count, style->font_name);
+            font_names_total_len += strlen(style->font_name);
+        }
         for (i = 0; i < ass->styles_count; i++) {
             int found = 0;
+            if (!ass->styles[i].font_name)
+                continue;
             for (j = 0; j < s->font_count; j++) {
                 if (!strcmp(s->fonts[j], ass->styles[i].font_name)) {
                     found = 1;