diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-01-07 12:33:47 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-01-07 12:33:47 -0500 |
commit | 7e0467e79d9d4e561adc6c844e8ef481d8a6a7cc (patch) | |
tree | 3665697f3f43773cc0e74954145bb754696a6a8a /src/eval.c | |
parent | 4a36bb92a5bbdc41965a6d2c6eae6cdca5983474 (diff) | |
download | bfs-7e0467e79d9d4e561adc6c844e8ef481d8a6a7cc.tar.xz |
eval: Check for xbasename() allocation failure
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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; } |