summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-01-07 12:33:47 -0500
committerTavian Barnes <tavianator@tavianator.com>2024-01-07 12:33:47 -0500
commit7e0467e79d9d4e561adc6c844e8ef481d8a6a7cc (patch)
tree3665697f3f43773cc0e74954145bb754696a6a8a /src
parent4a36bb92a5bbdc41965a6d2c6eae6cdca5983474 (diff)
downloadbfs-7e0467e79d9d4e561adc6c844e8ef481d8a6a7cc.tar.xz
eval: Check for xbasename() allocation failure
Diffstat (limited to 'src')
-rw-r--r--src/eval.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c
index 49c4aff..130b366 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -591,6 +591,7 @@ done:
* -i?name test.
*/
bool eval_name(const struct bfs_expr *expr, struct bfs_eval *state) {
+ bool ret = false;
const struct BFTW *ftwbuf = state->ftwbuf;
const char *name = ftwbuf->path + ftwbuf->nameoff;
@@ -599,9 +600,15 @@ bool eval_name(const struct bfs_expr *expr, struct bfs_eval *state) {
// Any trailing slashes are not part of the name. This can only
// happen for the root path.
name = copy = xbasename(name);
+ if (!name) {
+ eval_report_error(state);
+ goto done;
+ }
}
- bool ret = eval_fnmatch(expr, name);
+ ret = eval_fnmatch(expr, name);
+
+done:
free(copy);
return ret;
}