This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch release/8.0 in repository ffmpeg.
commit 2812961c5df055122fcea6a49ddd45d92b194c1f Author: Michael Niedermayer <[email protected]> AuthorDate: Sun May 17 13:45:38 2026 +0200 Commit: Michael Niedermayer <[email protected]> CommitDate: Sun Jun 14 04:59:05 2026 +0200 avfilter/vf_drawtext: don't double-free glyph that has been cached in tree Reproducer: ffmpeg -f lavfi -i color=s=640x120:d=1 \ -vf "drawtext=fontfile=/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf:\ text='FFmpeg':fontsize=109:fontcolor=white:x=20:y=35" \ -frames:v 1 out.png Signed-off-by: Michael Niedermayer <[email protected]> (cherry picked from commit c51789b052dc87e741fa3d02afe7ee83ed370373) Signed-off-by: Michael Niedermayer <[email protected]> --- libavfilter/vf_drawtext.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 3335a19736..ec344cd6ac 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -735,11 +735,13 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code, in FT_Vector shift; struct AVTreeNode *node = NULL; int ret = 0; + int cached = 0; /* get glyph */ dummy.code = code; dummy.fontsize = s->fontsize; glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL); + cached = !!glyph; if (!glyph) { if (FT_Load_Glyph(s->face, code, s->ft_load_flags)) { return AVERROR(EINVAL); @@ -756,11 +758,12 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code, in goto error; } if (s->borderw) { - glyph->border_glyph = glyph->glyph; - if (FT_Glyph_StrokeBorder(&glyph->border_glyph, s->stroker, 0, 0)) { + FT_Glyph tmp = glyph->glyph; + if (FT_Glyph_StrokeBorder(&tmp, s->stroker, 0, 0)) { ret = AVERROR_EXTERNAL; goto error; } + glyph->border_glyph = tmp; } /* measure text height to calculate text_height (or the maximum text height) */ FT_Glyph_Get_CBox(glyph->glyph, FT_GLYPH_BBOX_SUBPIXELS, &glyph->bbox); @@ -771,13 +774,15 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code, in goto error; } av_tree_insert(&s->glyphs, glyph, glyph_cmp, &node); + cached = 1; } else { if (s->borderw && !glyph->border_glyph) { - glyph->border_glyph = glyph->glyph; - if (FT_Glyph_StrokeBorder(&glyph->border_glyph, s->stroker, 0, 0)) { + FT_Glyph tmp = glyph->glyph; + if (FT_Glyph_StrokeBorder(&tmp, s->stroker, 0, 0)) { ret = AVERROR_EXTERNAL; goto error; } + glyph->border_glyph = tmp; } } @@ -816,10 +821,13 @@ static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code, in return 0; error: - if (glyph && glyph->glyph) - FT_Done_Glyph(glyph->glyph); - - av_freep(&glyph); + if (glyph && !cached) { + if (glyph->border_glyph && glyph->border_glyph != glyph->glyph) + FT_Done_Glyph(glyph->border_glyph); + if (glyph->glyph) + FT_Done_Glyph(glyph->glyph); + av_freep(&glyph); + } av_freep(&node); return ret; } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
