mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-07-23 12:18:31 +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);
|
typename, ambiguous);
|
||||||
if (found) {
|
if (found) {
|
||||||
if (obj) {
|
if (obj) {
|
||||||
if (ambiguous) {
|
|
||||||
*ambiguous = true;
|
*ambiguous = true;
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
obj = found;
|
obj = found;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambiguous && *ambiguous) {
|
if (*ambiguous) {
|
||||||
return NULL;
|
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,
|
Object *object_resolve_path_type(struct uc_struct *uc, const char *path, const char *typename,
|
||||||
bool *ambiguous)
|
bool *ambiguousp)
|
||||||
{
|
{
|
||||||
Object *obj;
|
Object *obj;
|
||||||
gchar **parts;
|
gchar **parts;
|
||||||
|
@ -1507,11 +1505,12 @@ Object *object_resolve_path_type(struct uc_struct *uc, const char *path, const c
|
||||||
assert(parts);
|
assert(parts);
|
||||||
|
|
||||||
if (parts[0] == NULL || strcmp(parts[0], "") != 0) {
|
if (parts[0] == NULL || strcmp(parts[0], "") != 0) {
|
||||||
if (ambiguous) {
|
bool ambiguous = false;
|
||||||
*ambiguous = false;
|
|
||||||
}
|
|
||||||
obj = object_resolve_partial_path(uc, object_get_root(NULL), parts,
|
obj = object_resolve_partial_path(uc, object_get_root(NULL), parts,
|
||||||
typename, ambiguous);
|
typename, &ambiguous);
|
||||||
|
if (ambiguousp) {
|
||||||
|
*ambiguousp = ambiguous;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
obj = object_resolve_abs_path(uc, object_get_root(NULL), parts, typename, 1);
|
obj = object_resolve_abs_path(uc, object_get_root(NULL), parts, typename, 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue