]> spindle.queued.net Git - midori/commitdiff
Check that g_utf8_normalize was non-NULL, fallback otherwise
authorChristian Dywan <christian@twotoasts.de>
Sun, 27 Dec 2009 21:18:02 +0000 (22:18 +0100)
committerChristian Dywan <christian@twotoasts.de>
Sun, 27 Dec 2009 21:18:02 +0000 (22:18 +0100)
midori/midori-locationaction.c

index aad384ddd2f4e6f10ce101010f9d88f6542d8054..f05a9d1049bd277b937f2a9ace6bf1e8ea970cd5 100644 (file)
@@ -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);
         }