close potentially left open directory during an error condition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index b6a5311..16847fa 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -1655,7 +1655,7 @@ gw_load_got_paths(struct gw_trans *gw_trans)
if (d_cnt == -1) {
error = got_error_from_errno2("scandir",
gw_trans->gw_conf->got_repos_path);
- return error;
+ goto done;
}
for (d_i = 0; d_i < d_cnt; d_i++) {
@@ -1669,7 +1669,7 @@ gw_load_got_paths(struct gw_trans *gw_trans)
error = gw_init_gw_dir(&gw_dir, sd_dent[d_i]->d_name);
if (error)
- return error;
+ goto done;
error = gw_load_got_path(gw_trans, gw_dir);
if (error && error->code == GOT_ERR_NOT_GIT_REPO) {
@@ -1677,7 +1677,7 @@ gw_load_got_paths(struct gw_trans *gw_trans)
continue;
}
else if (error)
- return error;
+ goto done;
if (lstat(gw_dir->path, &st) == 0 && S_ISDIR(st.st_mode) &&
!got_path_dir_is_empty(gw_dir->path)) {
@@ -1686,7 +1686,7 @@ gw_load_got_paths(struct gw_trans *gw_trans)
gw_trans->repos_total++;
}
}
-
+done:
closedir(d);
return error;
}