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
1 changed files with 8 additions and 1 deletions

9
find.c
View File

@ -229,7 +229,14 @@ static struct {
static int
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