Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 May 2016 02:51:15 +0000 (UTC)
From:      Don Lewis <truckman@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300643 - head/bin/mv
Message-ID:  <201605250251.u4P2pFFM039028@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: truckman
Date: Wed May 25 02:51:15 2016
New Revision: 300643
URL: https://svnweb.freebsd.org/changeset/base/300643

Log:
  Close from_fd if malloc() fails to avoid a file descriptor leak.
  
  Reported by:	Coverity
  CID:		1007203
  MFC after:	1 week

Modified:
  head/bin/mv/mv.c

Modified: head/bin/mv/mv.c
==============================================================================
--- head/bin/mv/mv.c	Wed May 25 02:10:30 2016	(r300642)
+++ head/bin/mv/mv.c	Wed May 25 02:51:15 2016	(r300643)
@@ -286,6 +286,7 @@ fastcopy(const char *from, const char *t
 	}
 	if (bp == NULL && (bp = malloc((size_t)blen)) == NULL) {
 		warnx("malloc(%u) failed", blen);
+		(void)close(from_fd);
 		return (1);
 	}
 	while ((to_fd =



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