aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 0e3fe020..1aca9c8c 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -364,7 +364,7 @@ void xmkpath(char *path, int mode)
struct string_list *find_in_path(char *path, char *filename)
{
- struct string_list *rlist = NULL;
+ struct string_list *rlist = NULL, **prlist=&rlist;
char *cwd = xgetcwd();
for (;;) {
@@ -386,8 +386,9 @@ struct string_list *find_in_path(char *path, char *filename)
// Confirm it's not a directory.
if (!stat(rnext->str, &st) && S_ISREG(st.st_mode)) {
- rnext->next = rlist;
- rlist = rnext;
+ *prlist = rnext;
+ rnext->next = NULL;
+ prlist = &(rnext->next);
} else free(rnext);
if (!next) break;