diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-07-07 22:01:13 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-07-07 22:04:01 +0200 |
| commit | 960a35a02fa8c98036e73be8fee9ea3f1c0888e9 (patch) | |
| tree | 7d9f1195ec1ccf9ba8ea9d683c39c0beb40fbeab | |
| parent | 74b7f7a902d9916dddb07d6adb26c63e765a6349 (diff) | |
| download | slcl-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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; } |
