From 05e10ce5ac75eb2a0cbecc0ee477d7e1b6f7edcf Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Fri, 14 Nov 2025 16:53:07 +0800 Subject: [PATCH] avfilter/vf_drawtext: fix call GET_UTF8 with invalid argument For GET_UTF8(val, GET_BYTE, ERROR), val has type of uint32_t, GET_BYTE must return an unsigned integer, otherwise signed extension happened due to val= (GET_BYTE), and GET_UTF8 went to the error path. This bug incidentally cancelled the bug where hb_buffer_add_utf8 was being called with incorrect argument, allowing drawtext to function correctly on x86 and macOS ARM, which defined char as signed. However, on Linux and Android ARM environments, because char is unsigned by default, GET_UTF8 now returns the correct return, which unexpectedly revealed issue #20906. (cherry picked from commit a5cc0e5c9e752f98e38c2a95a0893faeb1f78fa9) Signed-off-by: Michael Niedermayer --- libavfilter/vf_drawtext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index d748f2cfc4..817fb161d3 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1669,7 +1669,7 @@ static int measure_text(AVFilterContext *ctx, TextMetrics *metrics) { DrawTextContext *s = ctx->priv; char *text = s->expanded_text.str; - char *textdup = NULL, *start = NULL; + char *textdup = NULL; int width64 = 0, w64 = 0; int cur_min_y64 = 0, first_max_y64 = -32000; int first_min_x64 = 32000, last_max_x64 = -32000; @@ -1679,7 +1679,7 @@ static int measure_text(AVFilterContext *ctx, TextMetrics *metrics) Glyph *glyph = NULL; int i, tab_idx = 0, last_tab_idx = 0, line_offset = 0; - char* p; + uint8_t *start, *p; int ret = 0; // Count the lines and the tab characters