aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-08-15 19:50:04 +0100
committerHarry Jeffery <harry@exec64.co.uk>2019-08-15 19:50:04 +0100
commita34b58d2e3d691e1db594b38c21a8f3e099d1b6c (patch)
tree2923507e6f28dd39ba3dbac74e04e7c60da112f9
parent837d96d1b3340a804ee08374a2838844f6bf4c4c (diff)
downloadimv-a34b58d2e3d691e1db594b38c21a8f3e099d1b6c.tar.gz
imv_navigator_add: Fix resource leak
-rw-r--r--src/navigator.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/navigator.c b/src/navigator.c
index 63db338..6d38c4d 100644
--- a/src/navigator.c
+++ b/src/navigator.c
@@ -75,6 +75,7 @@ int imv_navigator_add(struct imv_navigator *nav, const char *path,
struct stat path_info;
stat(path, &path_info);
if (S_ISDIR(path_info.st_mode)) {
+ int result = 0;
DIR *d = opendir(path);
if (d) {
struct dirent *dir;
@@ -88,16 +89,19 @@ int imv_navigator_add(struct imv_navigator *nav, const char *path,
int is_dir = S_ISDIR(new_path_info.st_mode);
if (is_dir && recursive) {
if (imv_navigator_add(nav, path_buf, recursive) != 0) {
- return 1;
+ result = 1;
+ break;
}
} else if (!is_dir) {
if (add_item(nav, path_buf) != 0) {
- return 1;
+ result = 1;
+ break;
}
}
}
closedir(d);
}
+ return result;
} else {
return add_item(nav, path);
}