summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerve Codina <herve.codina@celad.com>2019-10-02 12:12:55 +0200
committerHerve Codina <herve.codina.external@spherea.com>2019-10-02 13:31:54 +0200
commit27f903039d164c6ee47f16b2a56d59bb8bf57a50 (patch)
tree08a9e156eca27dd810996ba576d70d682909131b
parent4d6fd4da0861d2823f2e451feb7180f363e88486 (diff)
downloadgenimage-27f903039d164c6ee47f16b2a56d59bb8bf57a50.tar.gz
genimage-27f903039d164c6ee47f16b2a56d59bb8bf57a50.tar.xz
dir_size: close fd and dir when no longer used
Signed-off-by: Herve Codina <herve.codina@celad.com>
-rw-r--r--util.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/util.c b/util.c
index b1ec96f..42ee661 100644
--- a/util.c
+++ b/util.c
@@ -729,6 +729,7 @@ static unsigned long long dir_size(struct image *image, int dirfd,
if (dir == NULL) {
image_error(image, "failed to opendir '%s': %s", subdir,
strerror(errno));
+ close(fd);
return 0;
}
while ((d = readdir(dir)) != NULL) {
@@ -748,6 +749,8 @@ static unsigned long long dir_size(struct image *image, int dirfd,
}
size += ROUND_UP(st.st_size, blocksize);
}
+ closedir(dir);
+ close(fd);
return size + blocksize;
}