1 |
commit: bab8be1e6ef9998ca7285310a4fd135127442500 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jan 2 15:09:21 2020 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 2 15:09:21 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bab8be1e |
7 |
|
8 |
libq/tree: ensure we don't leak scandir results on sorted foreach_pkg |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
libq/tree.c | 3 +++ |
13 |
1 file changed, 3 insertions(+) |
14 |
|
15 |
diff --git a/libq/tree.c b/libq/tree.c |
16 |
index 186fb4d..49b2fa1 100644 |
17 |
--- a/libq/tree.c |
18 |
+++ b/libq/tree.c |
19 |
@@ -1341,9 +1341,12 @@ tree_foreach_pkg(tree_ctx *ctx, tree_pkg_cb callback, void *priv, |
20 |
} |
21 |
|
22 |
/* allow foreach to be called again on the same open tree */ |
23 |
+ if (ctx->do_sort) |
24 |
+ scandir_free(ctx->cat_de, ctx->cat_cnt); |
25 |
ctx->cat_de = NULL; |
26 |
ctx->cat_cur = 0; |
27 |
ctx->cat_cnt = 0; |
28 |
+ ctx->do_sort = 0; |
29 |
|
30 |
return ret; |
31 |
} |