From 8b7fdb7a56349f4e127c3c37ae0eca309aad6a03 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 27 Dec 2009 22:18:02 +0100 Subject: [PATCH] Check that g_utf8_normalize was non-NULL, fallback otherwise --- midori/midori-locationaction.c | 39 ++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index aad384dd..f05a9d10 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -755,21 +755,42 @@ midori_location_entry_completion_match_cb (GtkEntryCompletion* completion, match = FALSE; if (G_LIKELY (uri)) { - gchar* nkey = g_utf8_normalize (key, -1, G_NORMALIZE_ALL); - gchar* nuri = g_utf8_normalize (uri, -1, G_NORMALIZE_ALL); - gchar* fkey = g_utf8_casefold (nkey, -1); - gchar* furi = g_utf8_casefold (nuri, -1); + gchar* nkey; + gchar* fkey; + gchar* nuri; + gchar* furi; + + if ((nkey = g_utf8_normalize (key, -1, G_NORMALIZE_ALL))) + { + fkey = g_utf8_casefold (nkey, -1); + g_free (nkey); + } + else + fkey = g_utf8_casefold (key, -1); + if ((nuri = g_utf8_normalize (uri, -1, G_NORMALIZE_ALL))) + { + furi = g_utf8_casefold (nuri, -1); + g_free (nuri); + } + else + furi = g_utf8_casefold (uri, -1); g_free (uri); - g_free (nkey); - g_free (nuri); match = strstr (furi, fkey) != NULL; g_free (furi); if (!match && G_LIKELY (title)) { - gchar* ntitle = g_utf8_normalize (title, -1, G_NORMALIZE_ALL); - gchar* ftitle = g_utf8_casefold (ntitle, -1); - g_free (ntitle); + gchar* ntitle; + gchar* ftitle; + + if ((ntitle = g_utf8_normalize (title, -1, G_NORMALIZE_ALL))) + { + ftitle = g_utf8_casefold (ntitle, -1); + g_free (ntitle); + } + else + ftitle = g_utf8_casefold (title, -1); + match = strstr (ftitle, fkey) != NULL; g_free (ftitle); }