]> xenbits.xensource.com Git - libvirt.git/commitdiff
Don't dereference NULL in qemumonitorjsontest
authorJán Tomko <jtomko@redhat.com>
Fri, 20 Sep 2013 11:02:43 +0000 (13:02 +0200)
committerJán Tomko <jtomko@redhat.com>
Fri, 20 Sep 2013 11:46:13 +0000 (13:46 +0200)
In case of an error, qemuMonitorTestNewSimple returns NULL.
Error out instead of dereferencing it.

Found by Coverity, reported by John Ferlan.

tests/qemumonitorjsontest.c

index b451e8ee37d9181c4347226c6c51c7cfc399f959..0fb8d65ac8e0093f8d5b6ad5885c8d6919923e30 100644 (file)
@@ -960,6 +960,9 @@ testQemuMonitorJSONCPU(const void *data)
     bool running = false;
     virDomainPausedReason reason = 0;
 
+    if (!test)
+        return -1;
+
     if (qemuMonitorTestAddItem(test, "stop", "{\"return\": {}}") < 0 ||
         qemuMonitorTestAddItem(test, "query-status",
                                "{\"return\": {"
@@ -1016,6 +1019,9 @@ testQemuMonitorJSONSimpleFunc(const void *opaque)
     const char *reply = data->reply;
     int ret = -1;
 
+    if (!test)
+        return -1;
+
     if (!reply)
         reply = "{\"return\":{}}";