diff mbox

[2/7] qom: Handle property lookup failure in object_resolve_link

Message ID 20170628124850.12821-3-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng June 28, 2017, 12:48 p.m. UTC
Since we have made object_set_link_property a public function, it is
possible that it will be called with a nonexistent property name.  Let's
survive this error case and report error to avoid segfault in the future.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 qom/object.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/qom/object.c b/qom/object.c
index 3868370..dd9c3fa 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1470,7 +1470,10 @@  static Object *object_resolve_link(Object *obj, const char *name,
     Object *target;
 
     /* Go from link<FOO> to FOO.  */
-    type = object_property_get_type(obj, name, NULL);
+    type = object_property_get_type(obj, name, errp);
+    if (!type) {
+        return NULL;
+    }
     target_type = g_strndup(&type[5], strlen(type) - 6);
     target = object_resolve_path_type(path, target_type, &ambiguous);