Skip to contentSkip to conversation

qapi: Fix regression with '-netdev ?'

PATCH Superseded Eric Blake 1 participant 2 messages Oct 14, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 qapi: Fix regression with '-netdev ?'

Commit e36c714e causes 'qemu -netdev ?' to dump core, because the call to visit_end_union() is no longer conditional on whether *obj was allocated.

Reported by Marc-André Lureau <[email protected]>

---
 scripts/qapi-visit.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/qapi-visit.py +3 -1
index 9e99c3a..74748a2 100644
@@ -297,7 +297,9 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error
 out_obj:
     error_propagate(errp, err);
     err = NULL;
-    visit_end_union(v, !!(*obj)->u.data, &err);
+    if (*obj) {
+        visit_end_union(v, !!(*obj)->u.data, &err);
+    }
     error_propagate(errp, err);
     err = NULL;
     visit_end_struct(v, &err);
Signature · 1 line
2.4.3
author
#1 lore raw
Quoted 15 lines · Eric Blake

Commit e36c714e causes 'qemu -netdev ?' to dump core, because the call to visit_end_union() is no longer conditional on whether *obj was allocated.

Reported by Marc-André Lureau <[email protected]>

---
 scripts/qapi-visit.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/qapi-visit.py +0 -0
index 9e99c3a..74748a2 100644

scripts/qapi-visit.py void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error · line 302

Quoted 7 lines
scripts/qapi-visit.py +3 -1
@@ -297,7 +297,9 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s **obj, const char *name, Error
 out_obj:
     error_propagate(errp, err);
     err = NULL;
-    visit_end_union(v, !!(*obj)->u.data, &err);
+    if (*obj) {
+        visit_end_union(v, !!(*obj)->u.data, &err);
+    }

And of course, I managed to post a version that depends on patches not in the tree yet. v2 coming up.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org