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 <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510
Reviewed-by: Colin Walters
This commit is contained in:
Simon McVittie 2016-12-02 10:07:23 +00:00
parent 663e12feca
commit 1d697a5f30

View File

@ -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),