]> xenbits.xensource.com Git - libvirt.git/commit
util: json: Fix freeing of objects appended to virJSONValue
authorPeter Krempa <pkrempa@redhat.com>
Fri, 30 Mar 2018 09:12:57 +0000 (11:12 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 3 Apr 2018 11:34:33 +0000 (13:34 +0200)
commitea520f6b67f451c14cc6d53246ff34cafb948df7
tree8a81ba40f59d151082fd680e1c8228cba41da0be
parent5dda119a4416efb0de906d4675ae7146427f7e0c
util: json: Fix freeing of objects appended to virJSONValue

It was not possible to determine whether virJSONValueObjectAddVArgs and
the functions using it would consume a virJSONValue or not when used
with the 'a' or 'A' modifier depending on when the loop failed.

Fix this by passing in a pointer to the pointer so that it can be
cleared once it's successfully consumed and the callers don't have to
second-guess leaving a chance of leaking or double freeing the value
depending on the ordering.

Fix all callers to pass a double pointer too.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_agent.c
src/qemu/qemu_block.c
src/qemu/qemu_command.c
src/qemu/qemu_monitor_json.c
src/util/virjson.c
tests/qemublocktest.c