find: estrdup before basename

"The basename() function may modify the string pointed to by path..."
Thanks POSIX

Laslo: Changed the style a bit
This commit is contained in:
Evan Gates 2016-10-05 15:37:34 -07:00 committed by Laslo Hunhold
parent b7c73e2392
commit 0b27c0c9a0

9
find.c
View File

@ -229,7 +229,14 @@ static struct {
static int static int
pri_name(struct arg *arg) pri_name(struct arg *arg)
{ {
return !fnmatch((char *)arg->extra.p, basename(arg->path), 0); int ret;
char *path;
path = estrdup(arg->path);
ret = !fnmatch((char *)arg->extra.p, basename(path), 0);
free(path);
return ret;
} }
static int static int