From 8f62dfcdd39f8c2d208a2fd902cc09057638cbb7 Mon Sep 17 00:00:00 2001
From: nitinosiris <nitinwartkar58@gmail.com>
Date: Fri, 4 Jun 2021 17:45:18 +0530
Subject: [PATCH] cli: XDG Directories

If any environment doesn't have xdg directories set up
then it resulted in a SEG-fault. Adding a proper check solved it.

Fixes: #172
---
 src/tracker/tracker-index.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/tracker/tracker-index.c b/src/tracker/tracker-index.c
index 89ed32671a..7902f48dd7 100644
--- a/src/tracker/tracker-index.c
+++ b/src/tracker/tracker-index.c
@@ -324,11 +324,16 @@ print_list (GStrv    list,
 		else
 			continue;
 
-		str = tracker_term_ellipsize (path, len, TRACKER_ELLIPSIZE_START);
-		g_print ("%-*s " BOLD_BEGIN "%s" BOLD_END "\n",
-		         len, str,
-		         recursive ? "*" : "-");
-		g_free (str);
+		if (path) {
+			str = tracker_term_ellipsize (path, len, TRACKER_ELLIPSIZE_START);
+			g_print ("%-*s " BOLD_BEGIN "%s" BOLD_END "\n",
+		    	     len, str,
+		    	     recursive ? "*" : "-");
+			g_free (str);
+		}
+		else {
+			g_print("Could not expand XDG user directory %s", list[i]);
+		}
 	}
 }
 
-- 
GitLab

