aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorNRK <nrk@disroot.org>2022-06-17 18:14:56 +0200
committerGitea <gitea@fake.local>2022-06-25 08:27:01 +0200
commit4cf17d23492a4673a2c6addfa82e61c2117be003 (patch)
tree904bcfeb0ee5af4164edc4d87d847aad63e2bc48 /util.c
parentb28449e10c92c304434645872199d8f8cb2448b4 (diff)
downloadnsxiv-4cf17d23492a4673a2c6addfa82e61c2117be003.tar.zst
fix: memory leak in r_readdir()
reported by clang-tidy: `filename` gets leaked when this branch gets taken.
Diffstat (limited to 'util.c')
-rw-r--r--util.c4
1 files changed, 3 insertions, 1 deletions
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) {