commit:     f7d28b1055bc515d9e510329c2840c1993f75654
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 19:08:44 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 19:08:44 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f7d28b10

libq/tree: fix Coverity 206542 Resource leak

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

 libq/tree.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libq/tree.c b/libq/tree.c
index dc6ee61..c8ada5c 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -553,7 +553,10 @@ tree_next_pkg(tree_cat_ctx *cat_ctx)
                } while (ret == NULL);
        } else if (ctx->cachetype == CACHE_BINPKGS) {
                char *p = NULL;
+               ret = NULL;
                do {
+                       if (ret != NULL)
+                               tree_close_pkg(ret);
                        ret = tree_next_pkg_int(cat_ctx);
                } while (ret != NULL && (p = strstr(ret->name, ".tbz2")) == 
NULL);
                if (p != NULL)

Reply via email to