Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jan 2019 00:26:25 +0000 (UTC)
From:      Oleksandr Tymoshenko <gonzo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r343127 - head/usr.bin/compress
Message-ID:  <201901180026.x0I0QPOV073259@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gonzo
Date: Fri Jan 18 00:26:25 2019
New Revision: 343127
URL: https://svnweb.freebsd.org/changeset/base/343127

Log:
  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 <dcb314@hotmail.com>
  MFC after:	1 week

Modified:
  head/usr.bin/compress/compress.c

Modified: head/usr.bin/compress/compress.c
==============================================================================
--- head/usr.bin/compress/compress.c	Thu Jan 17 23:22:56 2019	(r343126)
+++ head/usr.bin/compress/compress.c	Fri Jan 18 00:26:25 2019	(r343127)
@@ -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;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901180026.x0I0QPOV073259>