commit:     6ac211da306deccd42717e05ebf132f3da61e053
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 19:14:44 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> 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 <grobian <AT> 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);

Reply via email to