]> git.proxmox.com Git - mirror_qemu.git/commit
qapi/expr.py: Check type of union and alternate 'data' member
authorJohn Snow <jsnow@redhat.com>
Wed, 21 Apr 2021 18:20:22 +0000 (14:20 -0400)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 30 Apr 2021 10:59:54 +0000 (12:59 +0200)
commit4918bb7defbdcb1e27cc2adf4e1604486d778ece
tree0082b34f878d1c7dc8cf42c493a2597de312f253
parent926bb8add7c549496c612fcd4a32f3cf37883c2a
qapi/expr.py: Check type of union and alternate 'data' member

Prior to this commit, specifying a non-object value here causes the QAPI
parser to crash in expr.py with a stack trace with (likely) an
AttributeError when we attempt to call that value's items() method.

This member needs to be an object (Dict), and not anything else. Add a
check for this with a nicer error message, and formalize that check with
new test cases that exercise that error.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210421182032.3521476-8-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/expr.py
tests/qapi-schema/alternate-data-invalid.err [new file with mode: 0644]
tests/qapi-schema/alternate-data-invalid.json [new file with mode: 0644]
tests/qapi-schema/alternate-data-invalid.out [new file with mode: 0644]
tests/qapi-schema/meson.build
tests/qapi-schema/union-invalid-data.err [new file with mode: 0644]
tests/qapi-schema/union-invalid-data.json [new file with mode: 0644]
tests/qapi-schema/union-invalid-data.out [new file with mode: 0644]