On Tue, Apr 17, 2018 at 12:22:18 -0400, John Ferlan wrote:
> If the "return" is not in the reply, then the subsequent
> virJSONValueGetType will not be happy.
>
> Found by Coverity
>
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
> src/qemu/qemu_monitor_json.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 410fa178b2..681c0575c3 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -423,7 +423,12 @@ qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
> if (qemuMonitorJSONCheckError(cmd, reply) < 0)
This checks that the reply indeed has a key named 'return'.
> return -1;
>
> - data = virJSONValueObjectGet(reply, "return");
So this is not possible to fail.
> + if (!(data = virJSONValueObjectGet(reply, "return"))) {
> + virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("missing 'return' for returned data"));
> + return -1;
> + }
> +
> if (virJSONValueGetType(data) != type) {
> char *cmdstr = virJSONValueToString(cmd, false);
> char *retstr = virJSONValueToString(data, false);
> --
> 2.13.6
>
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list