qemu/scripts
Markus Armbruster cbf97d5b79 qapi: Fix visit_type_STRUCT() not to fail for null object
To make deallocating partially constructed objects work, the
visit_type_STRUCT() need to succeed without doing anything when passed
a null object.

Commit cdd2b228b9 "qapi: Smooth visitor error checking in generated
code" broke that.  To reproduce, run tests/test-qobject-input-visitor
with AddressSanitizer:

    ==4353==ERROR: LeakSanitizer: detected memory leaks

    Direct leak of 16 byte(s) in 1 object(s) allocated from:
	#0 0x7f192d0c5d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
	#1 0x7f192cd21b10 in g_malloc0 (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x51b10)
	#2 0x556725f6bbee in visit_next_list qapi/qapi-visit-core.c:86
	#3 0x556725f49e15 in visit_type_UserDefOneList tests/test-qapi-visit.c:474
	#4 0x556725f4489b in test_visitor_in_fail_struct_in_list tests/test-qobject-input-visitor.c:1086
	#5 0x7f192cd42f29  (/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x72f29)

    SUMMARY: AddressSanitizer: 16 byte(s) leaked in 1 allocation(s).

Test case /visitor/input/fail/struct-in-list feeds a list with a bad
element to the QObject input visitor.  Visiting that element duly
fails, and aborts the visit with the list only partially constructed:
the faulty object is null.  Cleaning up the partially constructed list
visits that null object, fails, and aborts the visit before the list
node gets freed.

Fix the the generated visit_type_STRUCT() to succeed for null objects.

Fixes: cdd2b228b9
Reported-by: Li Qiang <liq3ea@163.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20200716150617.4027356-1-armbru@redhat.com>
Tested-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
2020-07-21 14:38:23 +02:00
..
ci GitLab Gating CI: introduce pipeline-status contrib script 2020-07-13 11:40:52 +02:00
coccinelle scripts: Coccinelle script to use ERRP_GUARD() 2020-07-10 15:18:09 +02:00
coverity-scan * Miscellaneous fixes and feature enablement (many) 2020-06-12 23:06:22 +01:00
kvm scripts/kvm/vmxcap: Use Python 3 interpreter and add pseudo-main() 2020-05-31 13:56:46 +02:00
modules scripts/modules/module_block: Use Python 3 interpreter & add pseudo-main 2020-05-31 13:56:46 +02:00
oss-fuzz fuzz: add oss-fuzz build-script 2020-06-15 18:26:46 +02:00
performance scripts/performance: Add dissect.py script 2020-07-14 22:22:22 +02:00
qapi qapi: Fix visit_type_STRUCT() not to fail for null object 2020-07-21 14:38:23 +02:00
qemu-guest-agent
qemugdb scripts/qemugdb: Remove shebang header 2020-05-31 13:56:46 +02:00
qmp python: remove more instances of sys.version_info 2020-05-31 18:25:07 +02:00
simplebench scripts/simplebench: add example usage of simplebench 2020-03-17 21:09:26 -04:00
tracetool tracetool: work around ust <sys/sdt.h> include conflict 2020-07-07 16:07:14 +01:00
travis
analyse-9p-simpletrace.py drop "from __future__ import print_function" 2020-02-07 15:15:16 +01:00
analyse-locks-simpletrace.py drop "from __future__ import print_function" 2020-02-07 15:15:16 +01:00
analyze-inclusions
analyze-migration.py python: remove more instances of sys.version_info 2020-05-31 18:25:07 +02:00
archive-source.sh archive-source: also create a stash for submodules 2019-07-23 15:53:25 +01:00
checkpatch.pl checkpatch: Change occurences of 'kernel' to 'qemu' in user messages 2020-07-10 18:02:23 -04:00
clean-header-guards.pl
clean-includes scripts/clean-includes: Mark 'qemu/qemu-plugin.h' as special header 2020-06-08 16:59:29 +01:00
cleanup-trace-events.pl
cocci-macro-file.h
coverity-model.c
create_config create_config: remove $(CONFIG_SOFTMMU) hack 2019-07-15 20:58:37 +02:00
decodetree.py Remove the CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE switch 2020-07-13 11:40:52 +02:00
device-crash-test drop "from __future__ import print_function" 2020-02-07 15:15:16 +01:00
disas-objdump.pl
dump-guest-memory.py drop "from __future__ import print_function" 2020-02-07 15:15:16 +01:00
extract-vsssdk-headers
feature_to_c.sh
fix-multiline-comments.sh
gensyscalls.sh scripts: add a script to generate syscall_nr.h 2020-03-20 16:02:00 +01:00
get_maintainer.pl softmmu: move vl.c to softmmu/ 2020-02-22 08:26:47 +00:00
git-submodule.sh git: Make submodule check only needed modules 2020-02-13 11:31:58 +01:00
git.orderfile maint: Include top-level *.rst files early in git diff 2020-03-09 15:59:31 +01:00
hxtool hxtool: Remove Texinfo generation support 2020-03-12 11:14:05 +00:00
hxtool-conv.pl scripts/hxtool-conv: Archive script used in qemu-options.hx conversion 2020-03-06 10:05:24 +00:00
kernel-doc kernel-doc: Use c:struct for Sphinx 3.0 and later 2020-04-14 17:15:33 +01:00
make-release make-release: pull in edk2 submodules so we can build it from tarballs 2019-10-07 14:54:45 +02:00
minikconf.py minikconf: explicitly set encoding to UTF-8 2020-06-23 15:46:05 +01:00
qapi-gen.py drop "from __future__ import print_function" 2020-02-07 15:15:16 +01:00
qemu-binfmt-conf.sh scripts/qemu-binfmt-conf: Update for sparc64 2019-11-06 13:28:27 +01:00
qemu-gdb.py scripts/qemu-gdb: Use Python 3 interpreter 2020-05-31 13:56:46 +02:00
qemu-trace-stap trace: update qemu-trace-stap to Python 3 2020-01-13 16:42:20 +00:00
refresh-pxe-roms.sh
render_block_graph.py python/qmp.py: re-absorb MonitorResponseError 2020-07-14 22:22:22 +02:00
replay-dump.py drop "from __future__ import print_function" 2020-02-07 15:15:16 +01:00
shaderinclude.pl
show-fixed-bugs.sh
signrom.py drop "from __future__ import print_function" 2020-02-07 15:15:16 +01:00
simpletrace.py drop "from __future__ import print_function" 2020-02-07 15:15:16 +01:00
switch-timer-api
tap-driver.pl scripts: improve message when TAP based tests fail 2020-07-10 19:26:55 -04:00
tap-merge.pl
texi2pod.pl texi2pod: parse @include directives outside "@c man" blocks 2020-03-06 10:04:57 +00:00
tracetool.py scripts/tracetool: Update maintainer email address 2020-06-24 11:21:00 +01:00
update-linux-headers.sh virtiofsd: Pull in kernel's fuse.h 2020-01-23 16:41:36 +00:00
update-mips-syscall-args.sh linux-user,mips: update syscall-args-o32.c.inc 2020-03-20 16:02:00 +01:00
update-syscalltbl.sh linux-user, scripts: add a script to update syscall.tbl 2020-03-20 16:02:00 +01:00
vmstate-static-checker.py drop "from __future__ import print_function" 2020-02-07 15:15:16 +01:00