summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2016-05-25 02:51:15 +0000
committertruckman <truckman@FreeBSD.org>2016-05-25 02:51:15 +0000
commit36fa61883428b677cc1cbf35c851cf4dbbf4990b (patch)
treedb703ac0460c38c44d91419fbcdded3bbd3cad5b /bin
parent7fa8459fdb5367b97611bd13ebda4810a9261f4e (diff)
downloadFreeBSD-src-36fa61883428b677cc1cbf35c851cf4dbbf4990b.zip
FreeBSD-src-36fa61883428b677cc1cbf35c851cf4dbbf4990b.tar.gz
Close from_fd if malloc() fails to avoid a file descriptor leak.
Reported by: Coverity CID: 1007203 MFC after: 1 week
Diffstat (limited to 'bin')
-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 c19f6a0..9a300e6 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -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 =
OpenPOWER on IntegriCloud