commit: 74aeefacd106fcf87e755f2d1a53b0c7bc9f2e10 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Mon May 25 11:19:38 2020 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Mon May 25 11:19:38 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=74aeefac
libq/tree: fix Coverity 210534 tree_close_pkg can be called from tree_open_pkg, which will then free the pointer de->d_name, which should only be freed by scandir_free. Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> libq/tree.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libq/tree.c b/libq/tree.c index d313f3b..e4c4eb7 100644 --- a/libq/tree.c +++ b/libq/tree.c @@ -399,6 +399,7 @@ tree_open_pkg(tree_cat_ctx *cat_ctx, const char *name) if (cat_ctx->ctx->query_atom != NULL) { (void)tree_get_atom(pkg_ctx, cat_ctx->ctx->query_atom->SLOT != NULL); if (atom_compare(pkg_ctx->atom, cat_ctx->ctx->query_atom) != EQUAL) { + pkg_ctx->name = NULL; tree_close_pkg(pkg_ctx); return NULL; }