From 17b8edcc6b6b2a0b3ba9efe16bbb3f6c0ac4785f Mon Sep 17 00:00:00 2001 From: truckman Date: Wed, 1 Jun 2016 17:30:50 +0000 Subject: [PATCH] MFC r300643 Close from_fd if malloc() fails to avoid a file descriptor leak. Reported by: Coverity CID: 1007203 git-svn-id: svn://svn.freebsd.org/base/stable/10@301147 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- bin/mv/mv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/mv/mv.c b/bin/mv/mv.c index a23b6daf6..ea629d2be 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 = -- 2.42.0