diff options
author | Rory Bradford <roryrjb@gmail.com> | 2021-04-11 10:03:27 +0100 |
---|---|---|
committer | Rory Bradford <roryrjb@gmail.com> | 2021-04-11 10:03:27 +0100 |
commit | f45b62412d70e752a3f5383e77f588665fe0f1bd (patch) | |
tree | 9b9f5786373bf262ebb92f46c6ab47eeaa9b1055 | |
parent | c5af93d9b0afd9ca21aadf6a389a9f454456acf1 (diff) | |
download | rf-f45b62412d70e752a3f5383e77f588665fe0f1bd.tar.gz |
Fix memory leak when not specifying any patterns
Signed-off-by: Rory Bradford <roryrjb@gmail.com>
-rw-r--r-- | rf.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/rf.c b/rf.c index c192bdf..b862f57 100644 --- a/rf.c +++ b/rf.c @@ -196,6 +196,7 @@ int main(int argc, char **argv) { .wholename = 0, }; + int exit_code = EXIT_SUCCESS; int ch; char *remainder; size_t len = 0; @@ -374,16 +375,19 @@ int main(int argc, char **argv) { }; free(patterns); - free_ignores(global_ignores); - free_ignores(config_ignores); - free_ignores(local_ignores); if (unmatched_error && switches.count == 0) { - exit(EXIT_FAILURE); + exit_code = EXIT_FAILURE; + goto bail; } } else { usage(NULL); } - exit(EXIT_SUCCESS); +bail: + free_ignores(global_ignores); + free_ignores(config_ignores); + free_ignores(local_ignores); + + exit(exit_code); } |