diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-10-16 16:33:23 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-10-19 21:37:15 +0200 |
commit | 0dd7b8232d38317abc195edc48434ac1fd3e80fd (patch) | |
tree | 16cebf6febb9546f8097de8c45e5828bc0f5dfda /libavcodec/movtextenc.c | |
parent | 8d4431955ccca80933a837e1bc7f44679039335b (diff) | |
download | ffmpeg-0dd7b8232d38317abc195edc48434ac1fd3e80fd.tar.gz |
avcodec/movtextenc: Don't presume every style to have a font
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>
Diffstat (limited to 'libavcodec/movtextenc.c')
-rw-r--r-- | libavcodec/movtextenc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c index 81e8c2e802..dcdbf16e08 100644 --- a/libavcodec/movtextenc.c +++ b/libavcodec/movtextenc.c @@ -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; |