summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Behlendorf <behlendorf1@llnl.gov>2007-03-21 17:19:55 -0400
committerTheodore Ts'o <tytso@mit.edu>2007-03-21 17:19:55 -0400
commitf1d6a0797b13c1b1c364ab4ee9b500e5455aeeeb (patch)
treeb3b9566d5ee3ef3ebca9f24be3c3cc89cce289dc
parent5f7fe7fe0e96965b9cb4f6d1e2fa08acc175d7be (diff)
downloade2fsprogs-f1d6a0797b13c1b1c364ab4ee9b500e5455aeeeb.tar.gz
[COVERITY] Fix (error case) file handle leak in util/subst program
Need to close old_f before returning since it had been successfully opened before. Coverity ID: 19: Resource Leak Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
-rw-r--r--util/ChangeLog5
-rw-r--r--util/subst.c4
2 files changed, 8 insertions, 1 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index 1381c5b1..e99d46ce 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,8 @@
+2007-03-21 Theodore Tso <tytso@mit.edu>
+
+ * subst.c (compare_file): Close old FILE handle if the new FILE
+ handle open failed.
+
2006-11-12 Theodore Tso <tytso@mit.edu>
* gen-tarball.in: Use E2FSPROGS_PKGVER to simplify script
diff --git a/util/subst.c b/util/subst.c
index 445d3186..fadf3287 100644
--- a/util/subst.c
+++ b/util/subst.c
@@ -279,8 +279,10 @@ static int compare_file(const char *outfn, const char *newfn)
if (!old_f)
return 0;
new_f = fopen(newfn, "r");
- if (!new_f)
+ if (!new_f) {
+ fclose(old_f);
return 0;
+ }
while (1) {
oldcp = fgets(oldbuf, sizeof(oldbuf), old_f);