aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-07-07 22:01:13 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-07-07 22:04:01 +0200
commit960a35a02fa8c98036e73be8fee9ea3f1c0888e9 (patch)
tree7d9f1195ec1ccf9ba8ea9d683c39c0beb40fbeab
parent74b7f7a902d9916dddb07d6adb26c63e765a6349 (diff)
downloadslcl-960a35a02fa8c98036e73be8fee9ea3f1c0888e9.tar.gz
main.c: Fix use-after-free on failed search_fn
When search_fn fails, it must free `r` before `results`, as the former is assigned based on the latter - otherwise, it would lead to undefined behaviour. So far, only memory allocation errors would make search_fn to fail.
-rw-r--r--main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/main.c b/main.c
index ef1dde3..048b1ba 100644
--- a/main.c
+++ b/main.c
@@ -610,8 +610,8 @@ static int search_fn(const char *const fpath, const struct stat *const sb,
return 0;
failure:
- free(results);
search_result_free(r);
+ free(results);
return -1;
}