diff options
author | NRK <nrk@disroot.org> | 2022-06-17 22:14:56 +0600 |
---|---|---|
committer | Gitea <gitea@fake.local> | 2022-06-25 08:27:01 +0200 |
commit | 4cf17d23492a4673a2c6addfa82e61c2117be003 (patch) | |
tree | 904bcfeb0ee5af4164edc4d87d847aad63e2bc48 | |
parent | b28449e10c92c304434645872199d8f8cb2448b4 (diff) |
fix: memory leak in r_readdir()
reported by clang-tidy: `filename` gets leaked when this branch gets
taken.
-rw-r--r-- | util.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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) { |