]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: qemumonitorutils: Don't crash on wrong monitor command
authorPeter Krempa <pkrempa@redhat.com>
Thu, 12 Jul 2018 11:27:40 +0000 (13:27 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 13 Jul 2018 12:15:59 +0000 (14:15 +0200)
virQEMUQAPISchemaPathGet returns success when a given schema path was
not found but the returned object is set to NULL. This meant that we'd
call testQEMUSchemaValidate with the schemaroot being NULL which lead to
a crash if a mistyped monitor command was tested.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
tests/qemumonitortestutils.c

index d857c381a4f3ee2dd9b74e745d27afbd824eaa33..15eba5898ef786213495566a84fcc63ef27c9825 100644 (file)
@@ -564,7 +564,8 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonitorTestPtr test,
     if (virAsprintf(&schemapath, "%s/arg-type", cmdname) < 0)
         goto cleanup;
 
-    if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) < 0) {
+    if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot) < 0 ||
+        !schemaroot) {
         if (qemuMonitorReportError(test,
                                    "command '%s' not found in QAPI schema",
                                    cmdname) == 0)