From f1d6a0797b13c1b1c364ab4ee9b500e5455aeeeb Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 21 Mar 2007 17:19:55 -0400 Subject: [PATCH] [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 --- util/ChangeLog | 5 +++++ util/subst.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/util/ChangeLog b/util/ChangeLog index 1381c5b..e99d46c 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,8 @@ +2007-03-21 Theodore Tso + + * subst.c (compare_file): Close old FILE handle if the new FILE + handle open failed. + 2006-11-12 Theodore Tso * gen-tarball.in: Use E2FSPROGS_PKGVER to simplify script diff --git a/util/subst.c b/util/subst.c index 445d318..fadf328 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); -- 1.8.3.1