From 0f11b42938f4ae32b2c80b1c0644b75e64da4ada Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 5 Feb 2016 12:37:50 -0600 Subject: Another fix from Josh Gao to avoid a null pointer dereference, and minor cleanup of previous commit. --- toys/posix/find.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/toys/posix/find.c b/toys/posix/find.c index 65beeb54..a9c35f41 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -315,14 +315,13 @@ static int do_find(struct dirtree *new) || !strcmp(s, "path") || !strcmp(s, "ipath")) { int i = (*s == 'i'); - char *arg = ss[1], *path = 0, *name = new->name; + char *arg = ss[1], *path = 0, *name = new ? new->name : arg; // Handle path expansion and case flattening if (new && s[i] == 'p') name = path = dirtree_path(new, 0); if (i) { if (check || !new) { - char *temp = new ? name : arg; - name = temp ? strlower(temp) : 0; + if (name) name = strlower(name); if (!new) { dlist_add(&TT.argdata, name); free(path); -- cgit v1.2.3