From 442c1853d1556610e96e41babdfb7b706f3d2ccf Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 25 Apr 2016 00:55:01 -0500 Subject: Fix find bug reported by Tom Marshall, add test for it, and while we're at it fix two tests looking for a too-specific error message (so TEST_HOST failed). --- toys/posix/find.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'toys/posix') diff --git a/toys/posix/find.c b/toys/posix/find.c index 303aada2..3b27225d 100644 --- a/toys/posix/find.c +++ b/toys/posix/find.c @@ -320,20 +320,16 @@ static int do_find(struct dirtree *new) // Handle path expansion and case flattening if (new && s[i] == 'p') name = path = dirtree_path(new, 0); if (i) { - if (check || !new) { - if (name) name = strlower(name); - if (!new) { - dlist_add(&TT.argdata, name); - free(path); - } else arg = ((struct double_list *)llist_pop(&argdata))->data; - } + if ((check || !new) && name) name = strlower(name); + if (!new) dlist_add(&TT.argdata, name); + else arg = ((struct double_list *)llist_pop(&argdata))->data; } if (check) { test = !fnmatch(arg, name, FNM_PATHNAME*(s[i] == 'p')); - free(path); if (i) free(name); } + free(path); } else if (!strcmp(s, "perm")) { if (check) { char *m = ss[1]; -- cgit v1.2.3