summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-04-13 19:41:26 +0200
committerDaniel Friesel <derf@finalrewind.org>2014-04-13 19:41:26 +0200
commit46405777e6d8e4e5dc6db6206a115e49413c9be1 (patch)
tree4e754e0739cb304a52a16eb401c19b123616387d /src
parent4b8d812d11a4c8d2b134d2987a878c9fce4bc138 (diff)
parent5f210b5b2b0b150acf8f4b5890c9811cd65e2aa9 (diff)
Merge branch 'segfaultScandirFree' of https://github.com/vorburger/feh into vorburger-segfaultScandirFree
Diffstat (limited to 'src')
-rw-r--r--src/filelist.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/filelist.c b/src/filelist.c
index 8d19e41..e06c6de 100644
--- a/src/filelist.c
+++ b/src/filelist.c
@@ -263,27 +263,27 @@ void add_file_to_filelist_recursively(char *origpath, unsigned char level)
default:
weprintf("Failed to scan directory %s:", path);
}
- }
-
- for (cnt = 0; cnt < n; cnt++) {
- if (strcmp(de[cnt]->d_name, ".")
- && strcmp(de[cnt]->d_name, "..")) {
- char *newfile;
-
- newfile = estrjoin("", path, "/", de[cnt]->d_name, NULL);
-
- /* This ensures we go down one level even if not fully recursive
- - this way "feh some_dir" expands to some_dir's contents */
- if (opt.recursive)
- add_file_to_filelist_recursively(newfile, FILELIST_CONTINUE);
- else
- add_file_to_filelist_recursively(newfile, FILELIST_LAST);
-
- free(newfile);
+ } else {
+ for (cnt = 0; cnt < n; cnt++) {
+ if (strcmp(de[cnt]->d_name, ".")
+ && strcmp(de[cnt]->d_name, "..")) {
+ char *newfile;
+
+ newfile = estrjoin("", path, "/", de[cnt]->d_name, NULL);
+
+ /* This ensures we go down one level even if not fully recursive
+ - this way "feh some_dir" expands to some_dir's contents */
+ if (opt.recursive)
+ add_file_to_filelist_recursively(newfile, FILELIST_CONTINUE);
+ else
+ add_file_to_filelist_recursively(newfile, FILELIST_LAST);
+
+ free(newfile);
+ }
+ free(de[cnt]);
}
- free(de[cnt]);
+ free(de);
}
- free(de);
closedir(dir);
} else if (S_ISREG(st.st_mode)) {
D(("Adding regular file %s to filelist\n", path));