aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-06-24 08:19:24 -0500
committerRob Landley <rob@landley.net>2014-06-24 08:19:24 -0500
commit0aad9e4395c3077ed82c58981e9495586d6c8a01 (patch)
treefc3dcdce90ad6b6ff9659fa0d1aec8c73ea2eb86 /lib
parent1748bdb6bfe48cfe122973d26ab15186ee925101 (diff)
downloadtoybox-0aad9e4395c3077ed82c58981e9495586d6c8a01.tar.gz
find_in_path() is supposed to work with a NULL path, but didn't. Fix it.
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/lib.c b/lib/lib.c
index fa0b777f..52675d56 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -194,10 +194,13 @@ struct string_list **splitpath(char *path, struct string_list **list)
struct string_list *find_in_path(char *path, char *filename)
{
struct string_list *rlist = NULL, **prlist=&rlist;
- char *cwd = xgetcwd();
+ char *cwd;
+ if (!path) return 0;
+
+ cwd = xgetcwd();
for (;;) {
- char *next = path ? strchr(path, ':') : NULL;
+ char *next = strchr(path, ':');
int len = next ? next-path : strlen(path);
struct string_list *rnext;
struct stat st;