Close from_fd if malloc() fails to avoid a file descriptor leak.

Reported by:	Coverity
CID:		1007203
MFC after:	1 week
This commit is contained in:
truckman 2016-05-25 02:51:15 +00:00
parent 7fa8459fdb
commit 36fa618834

View File

@ -286,6 +286,7 @@ fastcopy(const char *from, const char *to, struct stat *sbp)
}
if (bp == NULL && (bp = malloc((size_t)blen)) == NULL) {
warnx("malloc(%u) failed", blen);
(void)close(from_fd);
return (1);
}
while ((to_fd =