From b63800ac8f4302b3337449a2e0448aa9bbd0114f Mon Sep 17 00:00:00 2001 From: Oleksandr Tymoshenko Date: Fri, 18 Jan 2019 00:26:25 +0000 Subject: [PATCH] Fix descriptor/memory leak in compress(1) code This is mostly a style fix since the code in question is not called multiple times and doesn't have cummulative effect. PR: 204953 Submitted by: David Binderman MFC after: 1 week --- usr.bin/compress/compress.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.bin/compress/compress.c b/usr.bin/compress/compress.c index b7fbf41ece96..d50f08571e3b 100644 --- a/usr.bin/compress/compress.c +++ b/usr.bin/compress/compress.c @@ -322,6 +322,8 @@ decompress(const char *in, const char *out, int bits) if ((ofp = fopen(out, "w")) == NULL || (nr != 0 && fwrite(buf, 1, nr, ofp) != nr)) { cwarn("%s", out); + if (ofp) + (void)fclose(ofp); (void)fclose(ifp); return; }