From ebcc479eee740937e70a94a468effcf2126a572b Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Fri, 7 Jul 2017 18:30:52 -0300 Subject: qom: Fix ambiguous path detection when ambiguous=NULL object_resolve_path*() ambiguous path detection breaks when ambiguous==NULL and the object tree have 3 objects of the same type and only 2 of them are under the same parent. e.g.: /container/obj1 (TYPE_FOO) /container/obj2 (TYPE_FOO) /obj2 (TYPE_FOO) With the above tree, object_resolve_path_type("", TYPE_FOO, NULL) will incorrectly return /obj2, because the search inside "/container" will return NULL, and the match at "/obj2" won't be detected as ambiguous. Fix that by always calling object_resolve_partial_path() with a non-NULL ambiguous parameter. Test case included. Reported-by: Igor Mammedov Cc: Mark Cave-Ayland Signed-off-by: Eduardo Habkost Message-Id: <20170707213052.13087-3-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- tests/check-qom-proplist.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/check-qom-proplist.c') diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index f6e7823338..432b66585f 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -593,14 +593,17 @@ static void test_qom_partial_path(void) ambiguous = false; g_assert(!object_resolve_path_type("", TYPE_DUMMY, &ambiguous)); g_assert(ambiguous); + g_assert(!object_resolve_path_type("", TYPE_DUMMY, NULL)); ambiguous = false; g_assert(!object_resolve_path("obj2", &ambiguous)); g_assert(ambiguous); + g_assert(!object_resolve_path("obj2", NULL)); ambiguous = false; g_assert(object_resolve_path("obj1", &ambiguous) == obj1); g_assert(!ambiguous); + g_assert(object_resolve_path("obj1", NULL) == obj1); object_unparent(obj2b); object_unparent(cont1); -- cgit v1.2.3