fix: memory leak in r_readdir()
reported by clang-tidy: `filename` gets leaked when this branch gets taken.
This commit is contained in:
parent
b28449e10c
commit
4cf17d2349
4
util.c
4
util.c
@ -159,8 +159,10 @@ char* r_readdir(r_dir_t *rdir, bool skip_dotfiles)
|
|||||||
rdir->name[strlen(rdir->name)-1] == '/' ? "" : "/",
|
rdir->name[strlen(rdir->name)-1] == '/' ? "" : "/",
|
||||||
dentry->d_name);
|
dentry->d_name);
|
||||||
|
|
||||||
if (stat(filename, &fstats) < 0)
|
if (stat(filename, &fstats) < 0) {
|
||||||
|
free(filename);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (S_ISDIR(fstats.st_mode)) {
|
if (S_ISDIR(fstats.st_mode)) {
|
||||||
/* put subdirectory on the stack */
|
/* put subdirectory on the stack */
|
||||||
if (rdir->stlen == rdir->stcap) {
|
if (rdir->stlen == rdir->stcap) {
|
||||||
|
Loading…
Reference in New Issue
Block a user