summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2016-06-01 17:30:50 +0000
committertruckman <truckman@FreeBSD.org>2016-06-01 17:30:50 +0000
commited265b2890fdcb1fa5b9bbdaddfd54fb5e3cf2ed (patch)
tree2ee95fce85b917d408ad9f25e69d2670f9ae9911
parent10d7f27879527fd48fe5906f0141d54d5b2c69aa (diff)
downloadFreeBSD-src-ed265b2890fdcb1fa5b9bbdaddfd54fb5e3cf2ed.zip
FreeBSD-src-ed265b2890fdcb1fa5b9bbdaddfd54fb5e3cf2ed.tar.gz
MFC r300643
Close from_fd if malloc() fails to avoid a file descriptor leak. Reported by: Coverity CID: 1007203
-rw-r--r--bin/mv/mv.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index a23b6da..ea629d2 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -285,6 +285,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 =
OpenPOWER on IntegriCloud