If the "return" is not in the reply, then the subsequent
virJSONValueGetType will not be happy.

Found by Coverity

Signed-off-by: John Ferlan <[email protected]>
---
 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)
         return -1;
 
-    data = virJSONValueObjectGet(reply, "return");
+    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
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to