qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH qemu v2 2/2] object: Handle objects with no parents


From: Alexey Kardashevskiy
Subject: [Qemu-devel] [PATCH qemu v2 2/2] object: Handle objects with no parents
Date: Mon, 30 Apr 2018 16:25:36 +1000

At the moment object_get_canonical_path_component() crashes on assert()
if the object does not have a parent. Usually it is not called for
orphan objects but various HMP/QMP commands can do that (info mtree,
qom-get).

This adds few more tests in object_get_canonical_path() to prevent QEMU
from crashing.

Signed-off-by: Alexey Kardashevskiy <address@hidden>
---
 qom/object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qom/object.c b/qom/object.c
index 4677951..e0e300b 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1668,7 +1668,7 @@ gchar *object_get_canonical_path(Object *obj)
     Object *root = object_get_root();
     char *newpath, *path = NULL;
 
-    while (obj != root) {
+    while (obj && obj->parent && obj != root) {
         char *component = object_get_canonical_path_component(obj);
 
         if (path) {
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]