mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 00:05:36 +00:00
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. Backports commit ebcc479eee740937e70a94a468effcf2126a572b from qemu
This commit is contained in:
parent
1c0169842d
commit
570c064065
|
@ -1481,15 +1481,13 @@ static Object *object_resolve_partial_path(struct uc_struct *uc, Object *parent,
|
|||
typename, ambiguous);
|
||||
if (found) {
|
||||
if (obj) {
|
||||
if (ambiguous) {
|
||||
*ambiguous = true;
|
||||
}
|
||||
*ambiguous = true;
|
||||
return NULL;
|
||||
}
|
||||
obj = found;
|
||||
}
|
||||
|
||||
if (ambiguous && *ambiguous) {
|
||||
if (*ambiguous) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1498,7 +1496,7 @@ static Object *object_resolve_partial_path(struct uc_struct *uc, Object *parent,
|
|||
}
|
||||
|
||||
Object *object_resolve_path_type(struct uc_struct *uc, const char *path, const char *typename,
|
||||
bool *ambiguous)
|
||||
bool *ambiguousp)
|
||||
{
|
||||
Object *obj;
|
||||
gchar **parts;
|
||||
|
@ -1507,11 +1505,12 @@ Object *object_resolve_path_type(struct uc_struct *uc, const char *path, const c
|
|||
assert(parts);
|
||||
|
||||
if (parts[0] == NULL || strcmp(parts[0], "") != 0) {
|
||||
if (ambiguous) {
|
||||
*ambiguous = false;
|
||||
}
|
||||
bool ambiguous = false;
|
||||
obj = object_resolve_partial_path(uc, object_get_root(NULL), parts,
|
||||
typename, ambiguous);
|
||||
typename, &ambiguous);
|
||||
if (ambiguousp) {
|
||||
*ambiguousp = ambiguous;
|
||||
}
|
||||
} else {
|
||||
obj = object_resolve_abs_path(uc, object_get_root(NULL), parts, typename, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue