From 22e1b1610f622ca9e2a7e64593025a8d44bc7b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 18 Jan 2025 10:22:24 +0100 Subject: [PATCH] vt: combining chars: ensure 'key' is within range When there's a key collision, we increment the key and check again. When doing this, we need to ensure the key is withing range, and wrap around to 0 if the key value is too large. --- vt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vt.c b/vt.c index 95cfdd2e..2b5eb27d 100644 --- a/vt.c +++ b/vt.c @@ -845,6 +845,7 @@ action_utf8_print(struct terminal *term, char32_t wc) cc->chars[0], base, cc->count, wanted_count, cc->chars[wanted_count - 1], wc); #endif key++; + key &= CELL_COMB_CHARS_HI - CELL_COMB_CHARS_LO; collision_count++; continue; } @@ -856,6 +857,7 @@ action_utf8_print(struct terminal *term, char32_t wc) if (!match) { key++; + key &= CELL_COMB_CHARS_HI - CELL_COMB_CHARS_LO; collision_count++; continue; }