From 5558a1edf06f168068af564ea404169a1bba33b5 Mon Sep 17 00:00:00 2001 From: Ollie Date: Sat, 23 May 2026 16:41:44 +0200 Subject: [PATCH] WINGs/wfont_wl: remove stale text comparison in wl_text_width The optimization that skipped pango_layout_set_text when the text matched the previous layout content used pango_layout_get_text() which returns an internal pointer. This pointer comparison with arbitrary input text could read freed memory or trigger heap corruption in Pango internals when the layout state was stale. Always call pango_layout_set_text unconditionally. The cost is negligible (Pango internally short-circuits if text is identical). --- WINGs/wfont_wl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/WINGs/wfont_wl.c b/WINGs/wfont_wl.c index a9d517a..dfa2e98 100644 --- a/WINGs/wfont_wl.c +++ b/WINGs/wfont_wl.c @@ -110,9 +110,7 @@ static int wl_text_width(void *handle, const char *text, int len) { FontHandleWL *h = handle; - const char *prev = pango_layout_get_text(h->layout); - if (!prev || strncmp(text, prev, (size_t)len) != 0 || prev[len] != '\0') - pango_layout_set_text(h->layout, text, len); + pango_layout_set_text(h->layout, text, len); int w = 0; pango_layout_get_pixel_size(h->layout, &w, NULL); return w;