From ed6cc1ddb2ce94917516fcc934e3c82083872dfe Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 14 Dec 2022 23:55:19 +0000 Subject: [PATCH] guniprop.c: Avoid creating (temporarily) out-of-bounds pointers This is detected by UBSan on CHERI systems (e.g. Arm Morello) and could result in non-derefenceable pointers when compiled without optimizations. --- glib/guniprop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/glib/guniprop.c b/glib/guniprop.c index a8aa77646..61acad6e6 100644 --- a/glib/guniprop.c +++ b/glib/guniprop.c @@ -573,7 +573,7 @@ g_unichar_toupper (gunichar c) gunichar val = ATTTABLE (c >> 8, c & 0xff); if (val >= 0x1000000) { - const gchar *p = special_case_table + val - 0x1000000; + const gchar *p = special_case_table + (val - 0x1000000); val = g_utf8_get_char (p); } /* Some lowercase letters, e.g., U+000AA, FEMININE ORDINAL INDICATOR, @@ -613,8 +613,8 @@ g_unichar_tolower (gunichar c) gunichar val = ATTTABLE (c >> 8, c & 0xff); if (val >= 0x1000000) { - const gchar *p = special_case_table + val - 0x1000000; - return g_utf8_get_char (p); + const gchar *p = special_case_table + (val - 0x1000000); + return g_utf8_get_char (p); } else {