Krolyxon
Commit 4cf17d2

Branches

Refs →

nsxiv4cf17d2

fix: memory leak in r_readdir()

reported by clang-tidy: `filename` gets leaked when this branch gets
taken.
Author
NRK
Date
2022-06-17 22:14 +0600
Committer
Gitea · 2022-06-25 08:27 +0200
Parent
b28449e
Commit
4cf17d23492a4673a2c6addfa82e61c2117be003

+3 −1

1 file changed

  1. M util.c +3 −1
M util.c View
@@ -159,8 +159,10 @@ char* r_readdir(r_dir_t *rdir, bool skip_dotfiles)
159159 rdir->name[strlen(rdir->name)-1] == '/' ? "" : "/",
160160 dentry->d_name);
161161
162− if (stat(filename, &fstats) < 0)
162+ if (stat(filename, &fstats) < 0) {
163+ free(filename);
163164 continue;
165+ }
164166 if (S_ISDIR(fstats.st_mode)) {
165167 /* put subdirectory on the stack */
166168 if (rdir->stlen == rdir->stcap) {