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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id EBC82138350 for ; Sun, 19 Jan 2020 16:37:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 04286E08C3; Sun, 19 Jan 2020 16:37:27 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D6BC4E08C3 for ; Sun, 19 Jan 2020 16:37:26 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8588F34DCA1 for ; Sun, 19 Jan 2020 16:37:25 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3DE58D7 for ; Sun, 19 Jan 2020 16:37:24 +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: <1579451816.5996186e46b4ae4156b2b9bf4ebc022e7039a02f.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qmanifest.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 5996186e46b4ae4156b2b9bf4ebc022e7039a02f X-VCS-Branch: master Date: Sun, 19 Jan 2020 16:37: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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 4a3f3689-579d-4a6c-8fe5-a9012036737d X-Archives-Hash: 48ee4dfbb75d2b914e329b3c238fca4c commit: 5996186e46b4ae4156b2b9bf4ebc022e7039a02f Author: Fabian Groffen gentoo org> AuthorDate: Sun Jan 19 16:36:56 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sun Jan 19 16:36:56 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5996186e qmanifest: fix Coverity 206559 Resource leak Signed-off-by: Fabian Groffen gentoo.org> qmanifest.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/qmanifest.c b/qmanifest.c index d9452a4..de4bf9b 100644 --- a/qmanifest.c +++ b/qmanifest.c @@ -570,6 +570,7 @@ generate_dir(const char *dir, enum type_manifest mtype) } else if (mtype == CATEGORY_MANIFEST) { const char *mfest; gzFile mf; + const char *ret = str_manifest_gz; snprintf(path, sizeof(path), "%s/%s", dir, str_manifest_gz); if ((mf = gzopen(path, "wb9")) == NULL) { @@ -596,13 +597,13 @@ generate_dir(const char *dir, enum type_manifest mtype) if (mfest == NULL) { fprintf(stderr, "generating Manifest for %s failed!\n", path); - gzclose(mf); - return NULL; + tv[0].tv_sec = 0; + ret = NULL; + } else { + snprintf(path, sizeof(path), "%s/%s", + dentries[i], mfest); + write_hashes(tv, dir, path, "MANIFEST", NULL, mf); } - - snprintf(path, sizeof(path), "%s/%s", - dentries[i], mfest); - write_hashes(tv, dir, path, "MANIFEST", NULL, mf); } else if (s.st_mode & S_IFREG) { write_hashes(tv, dir, dentries[i], "DATA", NULL, mf); } /* ignore other "things" (like symlinks) as they @@ -624,7 +625,7 @@ generate_dir(const char *dir, enum type_manifest mtype) utimes(dir, tv); } - return str_manifest_gz; + return ret; } else if (mtype == EBUILD_MANIFEST) { char newmanifest[8192]; FILE *m;