From: Brian Behlendorf Date: Wed, 21 Mar 2007 21:19:55 +0000 (-0400) Subject: [COVERITY] Fix (error case) file handle leak in util/subst program X-Git-Tag: E2FSPROGS-1_40~103 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=f1d6a0797b13c1b1c364ab4ee9b500e5455aeeeb;p=tools%2Fe2fsprogs.git [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 --- 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);