nsxiv4cf17d2
fix: memory leak in r_readdir()
reported by clang-tidy: `filename` gets leaked when this branch gets taken.
+3 −1
1 file changed
- M util.c +3 −1
| @@ -159,8 +159,10 @@ char* r_readdir(r_dir_t *rdir, bool skip_dotfiles) | |||
| 159 | 159 | rdir->name[strlen(rdir->name)-1] == '/' ? "" : "/", | |
| 160 | 160 | dentry->d_name); | |
| 161 | 161 | ||
| 162 | − | if (stat(filename, &fstats) < 0) | |
| 162 | + | if (stat(filename, &fstats) < 0) { | |
| 163 | + | free(filename); | |
| 163 | 164 | continue; | |
| 165 | + | } | |
| 164 | 166 | if (S_ISDIR(fstats.st_mode)) { | |
| 165 | 167 | /* put subdirectory on the stack */ | |
| 166 | 168 | if (rdir->stlen == rdir->stcap) { | |