Mercurial > hg > toybox
changeset 1360:46f068aaa480 draft
find_in_path() is supposed to work with a NULL path, but didn't. Fix it.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 24 Jun 2014 08:19:24 -0500 |
parents | fa1a3b9eed6f |
children | b6226bf22826 |
files | lib/lib.c |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/lib.c Tue Jun 24 07:00:13 2014 -0500 +++ b/lib/lib.c Tue Jun 24 08:19:24 2014 -0500 @@ -194,10 +194,13 @@ 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;