From 36fa61883428b677cc1cbf35c851cf4dbbf4990b Mon Sep 17 00:00:00 2001 From: truckman 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 c19f6a047f9e..9a300e6f0e34 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 =