Don't dereference NULL in qemumonitorjsontest

In case of an error, qemuMonitorTestNewSimple returns NULL.
Error out instead of dereferencing it.

Found by Coverity, reported by John Ferlan.
This commit is contained in:
Ján Tomko committed 2013-09-20 13:46:13 +02:00
1 parent 83c24493df
commit 5b36ab900a
1 file changed
+6
+6
View 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\":{}}";