[glib] g_unichar_iswide_cjk: add a special case for U+0000



commit 1d697a5f3034b81f62ba04d1ea0e16436ff126ec
Author: Simon McVittie <smcv debian org>
Date:   Fri Dec 2 10:07:23 2016 +0000

    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

 glib/guniprop.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/glib/guniprop.c b/glib/guniprop.c
index 86a7068..3726c7a 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),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]