From 1d697a5f3034b81f62ba04d1ea0e16436ff126ec Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 2 Dec 2016 10:07:23 +0000 Subject: [PATCH] g_unichar_iswide_cjk: add a special case for U+0000 bsearch() is defined to search for a non-null key, so we can't search for NULL. The undefined behaviour sanitizer picks this up. Signed-off-by: Simon McVittie Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510 Reviewed-by: Colin Walters --- glib/guniprop.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/glib/guniprop.c b/glib/guniprop.c index 86a706806..3726c7ab3 100644 --- a/glib/guniprop.c +++ b/glib/guniprop.c @@ -503,6 +503,11 @@ g_unichar_iswide_cjk (gunichar c) if (g_unichar_iswide (c)) return TRUE; + /* bsearch() is declared attribute(nonnull(1)) so we can't validly search + * for a NULL key */ + if (c == 0) + return FALSE; + if (bsearch (GUINT_TO_POINTER (c), g_unicode_width_table_ambiguous, G_N_ELEMENTS (g_unicode_width_table_ambiguous),