commit:     ffa327d46b4aa0d02f3e0348103ff9aa5da5eae5
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 19 14:05:07 2025 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Apr 19 14:05:07 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ffa327d4

qmerge: attempt to do list elem free slightly different for Coverity 520177

Looks as if the analysis gets confused by the usage of two vars, so make
it more clear we're just saving a pointer to restore.

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

 qmerge.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 280b0c1..836973c 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2024 Gentoo Authors
+ * Copyright 2005-2025 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <[email protected]>
@@ -1749,17 +1749,17 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, 
set *keep,
 
        /* Then remove all dirs in reverse order */
        while (dirs != NULL) {
-               llist_char *list = dirs;
-               char *dir = list->data;
+               llist_char *list;
                int rm;
 
-               rm = pretend ? -1 : rmdir_r_at(portroot_fd, dir + 1);
+               rm = pretend ? -1 : rmdir_r_at(portroot_fd, dirs->data + 1);
                qprintf("%s%s%s %s%s%s/\n", rm ? YELLOW : GREEN, rm ? "---" : 
"<<<",
-                       NORM, DKBLUE, dir, NORM);
+                       NORM, DKBLUE, dirs->data, NORM);
 
-               dirs = dirs->next;
-               free(list->data);
-               free(list);
+               list = dirs->next;
+               free(dirs->data);
+               free(dirs);
+               dirs = list;
        }
 
        if (!pretend) {

Reply via email to