diff options
author | Kristian Rietveld <kris@gtk.org> | 2003-12-17 22:33:54 +0000 |
---|---|---|
committer | Kristian Rietveld <kristian@src.gnome.org> | 2003-12-17 22:33:54 +0000 |
commit | b1187d9e0edb325b6123e35e93b6547e483e6242 (patch) | |
tree | dbba9c5151fcd5c2799189777d817cc20f6f4001 /gtk | |
parent | 2a136e56b8e0603a3bd26f426bbf252380db8367 (diff) | |
download | gtk+-b1187d9e0edb325b6123e35e93b6547e483e6242.tar.gz |
only try to strcmp or strlen if we managed to normalize and casefold the
Wed Dec 17 23:31:19 2003 Kristian Rietveld <kris@gtk.org>
* gtk/gtktreeview.c (gtk_tree_view_search_equal_func): only
try to strcmp or strlen if we managed to normalize and casefold
the string correctly. Fixes crashes with non-UTF8 strings.
(#121617, Patch from Tim-Philipp Müller).
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtktreeview.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index ee5ee4128a..cfd58f4c9c 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -11608,8 +11608,8 @@ gtk_tree_view_search_equal_func (GtkTreeModel *model, gboolean retval = TRUE; gchar *normalized_string; gchar *normalized_key; - gchar *case_normalized_string; - gchar *case_normalized_key; + gchar *case_normalized_string = NULL; + gchar *case_normalized_key = NULL; GValue value = {0,}; GValue transformed = {0,}; gint key_len; @@ -11628,12 +11628,18 @@ gtk_tree_view_search_equal_func (GtkTreeModel *model, normalized_string = g_utf8_normalize (g_value_get_string (&transformed), -1, G_NORMALIZE_ALL); normalized_key = g_utf8_normalize (key, -1, G_NORMALIZE_ALL); - case_normalized_string = g_utf8_casefold (normalized_string, -1); - case_normalized_key = g_utf8_casefold (normalized_key, -1); - key_len = strlen (case_normalized_key); + if (normalized_string && normalized_key) + { + case_normalized_string = g_utf8_casefold (normalized_string, -1); + case_normalized_key = g_utf8_casefold (normalized_key, -1); + + key_len = strlen (case_normalized_key); - if (!strncmp (case_normalized_key, case_normalized_string, key_len)) + if (!strncmp (case_normalized_key, case_normalized_string, key_len)) + retval = FALSE; + } + else retval = FALSE; g_value_unset (&transformed); |