This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch release/8.1
in repository ffmpeg.

commit 734b17cb98962794c13a833572a02b3022aac339
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Thu May 28 23:43:08 2026 +0200
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Sun Jun 14 04:40:58 2026 +0200

    avfilter/vf_drawtext: shape_text_hb() free allocated things on error
    
    Fixes: memleak
    Found-by: Fairy
    
    Signed-off-by: Michael Niedermayer <[email protected]>
    (cherry picked from commit 77554d85d7ff1eb8ba1719ba2c917221e2d4ca3a)
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavfilter/vf_drawtext.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 0b79577821..2b9ddb1547 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1371,23 +1371,25 @@ static int draw_glyphs(AVFilterContext *ctx, AVFrame 
*frame,
 static int shape_text_hb(DrawTextContext *s, HarfbuzzData* hb, const char* 
text, int textLen)
 {
     hb->buf = hb_buffer_create();
-    if(!hb_buffer_allocation_successful(hb->buf)) {
-        return AVERROR(ENOMEM);
-    }
+    if(!hb_buffer_allocation_successful(hb->buf))
+        goto fail;
     hb_buffer_set_direction(hb->buf, HB_DIRECTION_LTR);
     hb_buffer_set_script(hb->buf, HB_SCRIPT_LATIN);
     hb_buffer_set_language(hb->buf, hb_language_from_string("en", -1));
     hb_buffer_guess_segment_properties(hb->buf);
     hb->font = hb_ft_font_create_referenced(s->face);
-    if(hb->font == NULL) {
-        return AVERROR(ENOMEM);
-    }
+    if(hb->font == NULL)
+        goto fail;
     hb_buffer_add_utf8(hb->buf, text, textLen, 0, -1);
     hb_shape(hb->font, hb->buf, NULL, 0);
     hb->glyph_info = hb_buffer_get_glyph_infos(hb->buf, &hb->glyph_count);
     hb->glyph_pos = hb_buffer_get_glyph_positions(hb->buf, &hb->glyph_count);
 
     return 0;
+fail:
+    hb_buffer_destroy(hb->buf);
+    hb->buf = NULL;
+    return AVERROR(ENOMEM);
 }
 
 static void hb_destroy(HarfbuzzData *hb)

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to