Commit 87d36885 authored by Maks Naumov's avatar Maks Naumov Committed by Matthias Clasen

Properly check result of g_utf8_get_char_validated()

g_utf8_get_char_validated() may return -1 or -2
return type is gunichar(guint32)

Therefore such checks like 'gunichar < 0' or 'gunichar > 0'
are always 'false' or 'true'(except when gunichar == 0).
Signed-off-by: default avatarMaks Naumov <maksqwe1@ukr.net>

https://bugzilla.gnome.org/show_bug.cgi?id=742774
parent 07cf489d
......@@ -1784,7 +1784,7 @@ gtk_builder_value_from_string (GtkBuilder *builder,
gunichar c;
g_value_init (value, G_TYPE_UINT);
c = g_utf8_get_char_validated (string, strlen (string));
if (c > 0)
if (c != 0 && c != (gunichar)-1 && c != (gunichar)-2)
g_value_set_uint (value, c);
return TRUE;
}
......
......@@ -195,7 +195,7 @@ get_previous_char (GtkIMContextThai *context_thai, gint offset)
if (offset == 0)
{
prev_char = g_utf8_get_char_validated (q, p - q);
if (prev_char < 0)
if (prev_char == (gunichar)-1 || prev_char == (gunichar)-2)
prev_char = 0;
}
g_free (surrounding);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment