[gtk+] Properly check result of g_utf8_get_char_validated()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Properly check result of g_utf8_get_char_validated()
- Date: Sun, 11 Jan 2015 20:46:22 +0000 (UTC)
commit 87d36885ac713badc5187f1d26044dbba9e13309
Author: Maks Naumov <maksqwe1 ukr net>
Date: Sun Jan 11 11:27:37 2015 -0800
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: Maks Naumov <maksqwe1 ukr net>
https://bugzilla.gnome.org/show_bug.cgi?id=742774
gtk/gtkbuilder.c | 2 +-
modules/input/gtkimcontextthai.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 7b7c166..b0775d2 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -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;
}
diff --git a/modules/input/gtkimcontextthai.c b/modules/input/gtkimcontextthai.c
index 254dfc7..73510c0 100644
--- a/modules/input/gtkimcontextthai.c
+++ b/modules/input/gtkimcontextthai.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]