commit:     e5a915ca4e9760ffd3b4c2dc4d6b22dd78b8b352
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 14 10:41:10 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Aug 14 10:41:10 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e5a915ca

qlist: Coverity 212181: guard against NULL-pointers

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qlist.c b/qlist.c
index 3652c0a..a6bcc43 100644
--- a/qlist.c
+++ b/qlist.c
@@ -529,8 +529,10 @@ int qlist_main(int argc, char **argv)
 
                array_for_each(overlays, n, overlay) {
                        vdb = tree_open(portroot, overlay);
-                       ret |= tree_foreach_pkg_sorted(vdb, qlist_cb, &state, 
NULL);
-                       tree_close(vdb);
+                       if (vdb != NULL) {
+                               ret |= tree_foreach_pkg_sorted(vdb, qlist_cb, 
&state, NULL);
+                               tree_close(vdb);
+                       }
                }
        } else {
                if (state.do_binpkgs)

Reply via email to