From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id AFD1E1384B4 for ; Thu, 26 Nov 2015 10:39:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9ED8B21C101; Thu, 26 Nov 2015 10:39:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CB2DD21C105 for ; Thu, 26 Nov 2015 10:39:28 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AC17F34074D for ; Thu, 26 Nov 2015 10:39:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A08ECB5D for ; Thu, 26 Nov 2015 10:39:24 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1448531308.58513b6cba580354031623c11049ab8e0a8e6970.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: quse.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 58513b6cba580354031623c11049ab8e0a8e6970 X-VCS-Branch: master Date: Thu, 26 Nov 2015 10:39:24 +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-Archives-Salt: 41c4ed41-ae7e-4880-b80d-18eaf0d97bdf X-Archives-Hash: 5ecec564b032e0eee2ef128e9026e158 commit: 58513b6cba580354031623c11049ab8e0a8e6970 Author: Mike Frysinger gentoo org> AuthorDate: Thu Nov 26 09:48:28 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Thu Nov 26 09:48:28 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=58513b6c quse: fix invalid close This happens to work normally as we only have fds {0,1,2} open and {3} is the active file we're working on. Since the f loop contains 3 (for an unrelated reason), we close the right fd. But if there are more/fewer fd's open at start, it might fail, and we leak the FILE* structure. Switch to closing the right file pointer to avoid all this mess. quse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quse.c b/quse.c index c7c1863..5ef88da 100644 --- a/quse.c +++ b/quse.c @@ -205,7 +205,7 @@ quse_describe_flag(unsigned int ind, unsigned int argc, char **argv) if (!strcmp(argv[i], buf)) printf(" %s%s%s:%s%s%s: %s\n", BOLD, de->d_name, NORM, BLUE, argv[i], NORM, p); } - close(f); + fclose(fp[0]); } closedir(d);