[PATCH] Don't dereference NULL in qemumonitorjsontest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]