From 8dd8cd00e21ee9f1ea5cdabc637c8e1a67c96f22 Mon Sep 17 00:00:00 2001 From: Don Lewis Date: Wed, 25 May 2016 02:51:15 +0000 Subject: [PATCH] Close from_fd if malloc() fails to avoid a file descriptor leak. Reported by: Coverity CID: 1007203 MFC after: 1 week --- bin/mv/mv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/mv/mv.c b/bin/mv/mv.c index c19f6a047f9..9a300e6f0e3 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 =