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 09E3C138353 for ; Sun, 19 Jan 2020 19:36:16 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 43119E09FA; Sun, 19 Jan 2020 19:36:15 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (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 21B26E09F9 for ; Sun, 19 Jan 2020 19:36:15 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 101E634E267 for ; Sun, 19 Jan 2020 19:36:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A2E9D10D for ; Sun, 19 Jan 2020 19:36: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: <1579461284.6ac211da306deccd42717e05ebf132f3da61e053.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qpkg.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 6ac211da306deccd42717e05ebf132f3da61e053 X-VCS-Branch: master Date: Sun, 19 Jan 2020 19:36: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: 76e87f72-b76f-4998-b4b7-cd5069c52006 X-Archives-Hash: 05eac8f7f0cfddb3f4786e12767b4228 commit: 6ac211da306deccd42717e05ebf132f3da61e053 Author: Fabian Groffen gentoo org> AuthorDate: Sun Jan 19 19:14:44 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sun Jan 19 19:14:44 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6ac211da qpkg: fix Coverity 206541 Explicit null dereference Signed-off-by: Fabian Groffen gentoo.org> qpkg.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/qpkg.c b/qpkg.c index 1eee7b1..419456c 100644 --- a/qpkg.c +++ b/qpkg.c @@ -96,14 +96,16 @@ qpkg_clean(char *dirp) } } - /* check which binpkgs exist in the known_pkgs (vdb or trees), such - * that the remainder is what we would clean */ - array_for_each(bins, n, binatomstr) { - if (contains_set(binatomstr, known_pkgs)) - xarraydelete_ptr(bins, n--); - } + if (known_pkgs != NULL) { + /* check which binpkgs exist in the known_pkgs (vdb or trees), such + * that the remainder is what we would clean */ + array_for_each(bins, n, binatomstr) { + if (contains_set(binatomstr, known_pkgs)) + xarraydelete_ptr(bins, n--); + } - free_set(known_pkgs); + free_set(known_pkgs); + } array_for_each(bins, n, binatomstr) { snprintf(buf, sizeof(buf), "%s/%s.tbz2", dirp, binatomstr);