From: Ramiro Polla Date: Thu, 15 Jul 2010 17:54:11 +0000 (-0300) Subject: Close manifest files after reading/writing them X-Git-Tag: v3.1~188 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d325739040adcb1b3742b782746c0d61fe4e5b52;p=thirdparty%2Fccache.git Close manifest files after reading/writing them --- diff --git a/manifest.c b/manifest.c index c759f1cb8..388000e5c 100644 --- a/manifest.c +++ b/manifest.c @@ -634,10 +634,17 @@ int manifest_put(const char *manifest_path, struct file_hash *object_hash, mf = read_manifest(f1); if (!mf) { cc_log("Failed to read manifest file"); + gzclose(f1); goto out; } } + if (f1) { + gzclose(f1); + } else { + close(fd1); + } + if (mf->n_objects > MAX_MANIFEST_ENTRIES) { /* * Normally, there shouldn't be many object entries in the @@ -673,6 +680,8 @@ int manifest_put(const char *manifest_path, struct file_hash *object_hash, add_object_entry(mf, object_hash, included_files); if (write_manifest(f2, mf)) { + gzclose(f2); + f2 = NULL; unlink(manifest_path); if (rename(tmp_file, manifest_path) == 0) { ret = 1; @@ -696,8 +705,5 @@ out: if (f2) { gzclose(f2); } - if (f1) { - gzclose(f1); - } return ret; }