dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0006-PATCH-test-vmstate-fix-bad-GTree-usage-use-after-fre.patch

d8ea84
From 930def8769940600dd7dd587ec2accd4a8b6e1f8 Mon Sep 17 00:00:00 2001
d8ea84
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
d8ea84
Date: Mon, 27 Feb 2023 16:02:51 +0000
f48e9e
Subject: [PATCH 6/7] [PATCH] test-vmstate: fix bad GTree usage, use-after-free
d8ea84
MIME-Version: 1.0
d8ea84
Content-Type: text/plain; charset=UTF-8
d8ea84
Content-Transfer-Encoding: 8bit
d8ea84
d8ea84
According to g_tree_foreach() documentation:
d8ea84
"The tree may not be modified while iterating over it (you can't
d8ea84
add/remove items)."
d8ea84
d8ea84
Fixes: 9a85e4b8f6 ("migration: Support gtree migration")
d8ea84
Cc: Eric Auger <eric.auger@redhat.com>
d8ea84
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
d8ea84
---
d8ea84
 tests/unit/test-vmstate.c | 3 +--
d8ea84
 1 file changed, 1 insertion(+), 2 deletions(-)
d8ea84
d8ea84
diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c
d8ea84
index 541bb4f63e..36b253eb67 100644
d8ea84
--- a/tests/unit/test-vmstate.c
d8ea84
+++ b/tests/unit/test-vmstate.c
d8ea84
@@ -1074,7 +1074,6 @@ static gboolean diff_tree(gpointer key, gpointer value, gpointer data)
d8ea84
     struct match_node_data d = {tp->tree2, key, value};
d8ea84
 
d8ea84
     g_tree_foreach(tp->tree2, tp->match_node, &d);
d8ea84
-    g_tree_remove(tp->tree1, key);
d8ea84
     return false;
d8ea84
 }
d8ea84
 
d8ea84
@@ -1084,7 +1083,7 @@ static void compare_trees(GTree *tree1, GTree *tree2,
d8ea84
     struct tree_cmp_data tp = {tree1, tree2, function};
d8ea84
 
d8ea84
     g_tree_foreach(tree1, diff_tree, &tp);
d8ea84
-    assert(g_tree_nnodes(tree1) == 0);
d8ea84
+    g_tree_destroy(g_tree_ref(tree1));
d8ea84
     assert(g_tree_nnodes(tree2) == 0);
d8ea84
 }
d8ea84
 
d8ea84
-- 
d8ea84
2.37.3
d8ea84