From 4cf17d23492a4673a2c6addfa82e61c2117be003 Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 17 Jun 2022 22:14:56 +0600 Subject: fix: memory leak in r_readdir() reported by clang-tidy: `filename` gets leaked when this branch gets taken. --- util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'util.c') diff --git a/util.c b/util.c index c207e60..48bf61e 100644 --- a/util.c +++ b/util.c @@ -159,8 +159,10 @@ char* r_readdir(r_dir_t *rdir, bool skip_dotfiles) rdir->name[strlen(rdir->name)-1] == '/' ? "" : "/", dentry->d_name); - if (stat(filename, &fstats) < 0) + if (stat(filename, &fstats) < 0) { + free(filename); continue; + } if (S_ISDIR(fstats.st_mode)) { /* put subdirectory on the stack */ if (rdir->stlen == rdir->stcap) { -- cgit v1.2.3