From 47b19cf1c341627eb796469f3793e5c26baea767 Mon Sep 17 00:00:00 2001 From: Evan Gates Date: Wed, 5 Oct 2016 15:37:34 -0700 Subject: [PATCH] find: estrdup before basename "The basename() function may modify the string pointed to by path..." Thanks POSIX --- find.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/find.c b/find.c index b331486..77f2935 100644 --- a/find.c +++ b/find.c @@ -229,7 +229,10 @@ static struct { static int pri_name(struct arg *arg) { - return !fnmatch((char *)arg->extra.p, basename(arg->path), 0); + char *path = estrdup(arg->path); + int ret = !fnmatch((char *)arg->extra.p, basename(path), 0); + free(path); + return ret; } static int -- 2.10.0