summaryrefslogtreecommitdiffstats
path: root/scripts/qapi
diff options
context:
space:
mode:
authorMarkus Armbruster2020-04-24 10:43:34 +0200
committerMarkus Armbruster2020-04-30 07:26:40 +0200
commit7111a86e1ba23ff8d59886df03d8a1cd6c5aab43 (patch)
treed9a8fc2157b797015477ed326f62620501417a9c /scripts/qapi
parentqapi: Clean up visitor's recovery from input with invalid type (diff)
downloadqemu-7111a86e1ba23ff8d59886df03d8a1cd6c5aab43.tar.gz
qemu-7111a86e1ba23ff8d59886df03d8a1cd6c5aab43.tar.xz
qemu-7111a86e1ba23ff8d59886df03d8a1cd6c5aab43.zip
qapi: Assert non-input visitors see only valid alternate tags
An alternate type's visit_type_FOO() fails when it runs into an invalid ->type. This is appropriate with an input visitor: visit_start_alternate() sets ->type according to the input, and bad input can lead to bad ->type. It should never happen with an output, clone or dealloc visitor: if it did, the alternate being output, cloned or deallocated would be messed up beyond repair. Assert that. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200424084338.26803-12-armbru@redhat.com>
Diffstat (limited to 'scripts/qapi')
-rw-r--r--scripts/qapi/visit.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
index 678109dfb5..d5d7a1031f 100644
--- a/scripts/qapi/visit.py
+++ b/scripts/qapi/visit.py
@@ -232,6 +232,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
case QTYPE_NONE:
abort();
default:
+ assert(visit_is_input(v));
error_setg(&err, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"%(name)s");
/* Avoid passing invalid *obj to qapi_free_%(c_name)s() */