From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 052A715808B for ; Sat, 12 Feb 2022 18:31:16 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 25C2FE0788; Sat, 12 Feb 2022 18:31:15 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0CE5DE0788 for ; Sat, 12 Feb 2022 18:31:15 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0DE2033FEF1 for ; Sat, 12 Feb 2022 18:31:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2F90D2D2 for ; Sat, 12 Feb 2022 18:31:12 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1644689740.219ba2dd9f748c6065c6485020f7de56623e1bc9.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qmerge.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 219ba2dd9f748c6065c6485020f7de56623e1bc9 X-VCS-Branch: master Date: Sat, 12 Feb 2022 18:31:12 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 0ea06840-48d9-493e-aeed-157278443b50 X-Archives-Hash: 3e9d5e4d8985d6a6ed2dd712ffc76cf6 commit: 219ba2dd9f748c6065c6485020f7de56623e1bc9 Author: Fabian Groffen gentoo org> AuthorDate: Sat Feb 12 18:15:40 2022 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sat Feb 12 18:15:40 2022 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=219ba2dd qmerge: fix Coverity file descriptor leak CID 207952 Leak would happen when opening file succeed, but statting it would fail. Unlikely, but better to take into account anyway. Signed-off-by: Fabian Groffen gentoo.org> qmerge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qmerge.c b/qmerge.c index a64447e..80affdb 100644 --- a/qmerge.c +++ b/qmerge.c @@ -1693,8 +1693,9 @@ unlink_empty(const char *buf) if (fd != -1 && stat(buf, &st) != -1) { if (st.st_size == 0) ret = unlink(buf); - close(fd); } + if (fd != -1) + close(fd); return ret; }