commit:     ab51b5e60db69f6ee6f2513fef7ce12ebc01af92
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May  3 11:44:40 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May  3 11:44:40 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ab51b5e6

libq/cache: fix crash when a category contains a non-directory

Bug: https://bugs.gentoo.org/684252
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/cache.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libq/cache.c b/libq/cache.c
index 9993002..0dbf483 100644
--- a/libq/cache.c
+++ b/libq/cache.c
@@ -160,6 +160,11 @@ cache_next_pkg(cache_cat_ctx *cat_ctx)
 
                                ctx->ebuilddir_cat_ctx =
                                        q_vdb_open_cat(pkgdir, 
ctx->ebuilddir_pkg_ctx->name);
+
+                               /* opening might fail if what we found wasn't a
+                                * directory or something */
+                               if (ctx->ebuilddir_cat_ctx == NULL)
+                                       return NULL;
                        }
 
                        ret = q_vdb_next_pkg(ctx->ebuilddir_cat_ctx);

Reply via email to