summary refs log tree commit diff
path: root/search.c
diff options
context:
space:
mode:
authorokan <okan>2017-04-25 13:40:33 +0000
committerokan <okan>2017-04-25 13:40:33 +0000
commit15b9a8fe27a72e58f1fb488ebf14c3fcae4b98a9 (patch)
treea9d3494480f8cb77b0fea53b684e32b3e662a876 /search.c
parent717e6c8167978bef3ffaba49322724e72cb78ba3 (diff)
downloadcwm-15b9a8fe27a72e58f1fb488ebf14c3fcae4b98a9.tar.gz
cwm-15b9a8fe27a72e58f1fb488ebf14c3fcae4b98a9.tar.xz
cwm-15b9a8fe27a72e58f1fb488ebf14c3fcae4b98a9.zip
The r1.36 menuq_add() conversion did this one wrong; fix by reverting to the
original code which adds to resultentry list, as opposed to the wrong one in
menuq_add(). Fixes crash noticed by at least Rickard Gustafsson.
Diffstat (limited to 'search.c')
-rw-r--r--search.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/search.c b/search.c
index 07e0e15..2f8897d 100644
--- a/search.c
+++ b/search.c
@@ -148,9 +148,10 @@ static void
 search_match_path_type(struct menu_q *menuq, struct menu_q *resultq,
     char *search, int flag)
 {
-	char 	 pattern[PATH_MAX];
-	glob_t	 g;
-	int	 i;
+	struct menu     *mi;
+	char 		 pattern[PATH_MAX];
+	glob_t		 g;
+	int		 i;
 
 	(void)strlcpy(pattern, search, sizeof(pattern));
 	(void)strlcat(pattern, "*", sizeof(pattern));
@@ -160,7 +161,9 @@ search_match_path_type(struct menu_q *menuq, struct menu_q *resultq,
 	for (i = 0; i < g.gl_pathc; i++) {
 		if ((flag & PATH_EXEC) && access(g.gl_pathv[i], X_OK))
 			continue;
-		menuq_add(resultq, NULL, "%s", g.gl_pathv[i]);
+		mi = xcalloc(1, sizeof(*mi));
+		(void)strlcpy(mi->text, g.gl_pathv[i], sizeof(mi->text));
+		TAILQ_INSERT_TAIL(resultq, mi, resultentry);
 	}
 	globfree(&g);
 }