[nautilus] search-hit: guard against g_filename_from_uri() return NULL



commit 75e219ebfdd3e32e9e421fe1a11b7f946693787e
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Sep 14 16:50:30 2012 -0400

    search-hit: guard against g_filename_from_uri() return NULL

 libnautilus-private/nautilus-search-hit.c |   30 +++++++++++++++-------------
 1 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/libnautilus-private/nautilus-search-hit.c b/libnautilus-private/nautilus-search-hit.c
index 7e7d8f1..1eee49e 100644
--- a/libnautilus-private/nautilus-search-hit.c
+++ b/libnautilus-private/nautilus-search-hit.c
@@ -72,20 +72,22 @@ nautilus_search_hit_compute_scores (NautilusSearchHit *hit,
 		guint dir_count;
 
 		hit_path = g_filename_from_uri (hit->details->uri, NULL, NULL);
-		hit_parent = g_path_get_dirname (hit_path);
-		g_free (hit_path);
-
-		dir_count = 0;
-		for (i = strlen (query_path); hit_parent[i] != '\0'; i++) {
-			if (G_IS_DIR_SEPARATOR (hit_parent[i]))
-				dir_count++;
-		}
-		g_free (hit_parent);
-
-		if (dir_count < 10) {
-			proximity_bonus = 100.0 - 10 * dir_count;
-		} else {
-			proximity_bonus = 0.0;
+		if (hit_path != NULL) {
+			hit_parent = g_path_get_dirname (hit_path);
+			g_free (hit_path);
+
+			dir_count = 0;
+			for (i = strlen (query_path); hit_parent[i] != '\0'; i++) {
+				if (G_IS_DIR_SEPARATOR (hit_parent[i]))
+					dir_count++;
+			}
+			g_free (hit_parent);
+
+			if (dir_count < 10) {
+				proximity_bonus = 100.0 - 10 * dir_count;
+			} else {
+				proximity_bonus = 0.0;
+			}
 		}
 	}
 	g_free (query_path);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]