In case of an error, qemuMonitorTestNewSimple returns NULL.
Error out instead of dereferencing it.
Found by Coverity, reported by John Ferlan.
---
Pushed as trivial.
tests/qemumonitorjsontest.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index b451e8e..0fb8d65 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -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\":{}}";
--
1.8.1.5