]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: check for json allocation failure
authorEric Blake <eblake@redhat.com>
Thu, 13 Oct 2011 00:10:24 +0000 (18:10 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 13 Oct 2011 18:24:39 +0000 (12:24 -0600)
Detected by Coverity.  Introduced in commit b1b5b51.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBlockInfo):
Avoid null dereference.

src/qemu/qemu_monitor_json.c

index 18d1c9f51d731218c87f10b41885fbb4992cb957..cd8f1e599cc921a7eb03a03224c5df9c82c1bfd1 100644 (file)
@@ -1364,6 +1364,9 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
     virJSONValuePtr reply = NULL;
     virJSONValuePtr devices;
 
+    if (!cmd)
+        return -1;
+
     ret = qemuMonitorJSONCommand(mon, cmd, &reply);
     if (ret == 0)
         ret = qemuMonitorJSONCheckError(cmd, reply);