svn commit: r301147 - stable/10/bin/mv

Don Lewis truckman at FreeBSD.org
Wed Jun 1 17:30:51 UTC 2016


Author: truckman
Date: Wed Jun  1 17:30:50 2016
New Revision: 301147
URL: https://svnweb.freebsd.org/changeset/base/301147

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

Modified:
  stable/10/bin/mv/mv.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/bin/mv/mv.c
==============================================================================
--- stable/10/bin/mv/mv.c	Wed Jun  1 17:29:15 2016	(r301146)
+++ stable/10/bin/mv/mv.c	Wed Jun  1 17:30:50 2016	(r301147)
@@ -285,6 +285,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 =


More information about the svn-src-all mailing list