commit:     52c46dc5d92943fad81d78b779bc53c617a4702c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan  7 20:44:51 2026 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan  7 20:44:51 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=52c46dc5

libq/dep: don't remove atoms in dep_flatten_tree

atom refs are used lateron for comparisons, so unsetting the pointer
causes crashes.  Clone the atom instead, such that it's clear for the
caller what to free, and also for dep_burn_tree that it can free its
atoms.

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

 libq/dep.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libq/dep.c b/libq/dep.c
index f49e764..6b41c8e 100644
--- a/libq/dep.c
+++ b/libq/dep.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2025 Gentoo Foundation
+ * Copyright 2005-2026 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <[email protected]>
@@ -381,8 +381,7 @@ dep_flatten_tree(dep_node *root, array_t *out)
 {
        if (root->type != DEP_NULL) {
                if (root->type == DEP_NORM) {
-                       xarraypush_ptr(out, root->atom);
-                       root->atom = NULL;
+                       xarraypush_ptr(out, atom_clone(root->atom));
                }
                if (root->children)
                        dep_flatten_tree(root->children, out);

Reply via email to