[glib] Protect against invalid characters

This commit is contained in:
Behdad Esfahbod 2011-08-07 00:59:12 -04:00
parent 144cd49a0e
commit f22e661147
1 changed files with 6 additions and 2 deletions

View File

@ -254,8 +254,10 @@ hb_glib_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
len = g_unichar_to_utf8 (a, utf8);
len += g_unichar_to_utf8 (b, utf8 + len);
normalized = g_utf8_normalize (utf8, len, G_NORMALIZE_NFC);
len = g_utf8_strlen (normalized, -1);
if (unlikely (!len))
return FALSE;
if (len == 1) {
*ab = g_utf8_get_char (normalized);
ret = TRUE;
@ -288,8 +290,10 @@ hb_glib_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
len = g_unichar_to_utf8 (ab, utf8);
normalized = g_utf8_normalize (utf8, len, G_NORMALIZE_NFD);
len = g_utf8_strlen (normalized, -1);
if (unlikely (!len))
return FALSE;
if (len == 1) {
*a = g_utf8_get_char (normalized);
*b = 0;