]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuMonitorJSONQueryRxFilter: Validate qemu reply prior parsing it
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 3 May 2016 08:44:13 +0000 (10:44 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 3 May 2016 12:18:02 +0000 (14:18 +0200)
Usually, the flow in this area of the code is as follows:

qemuMonitorJSONMakeCommand()
qemuMonitorJSONCommand()
qemuMonitorJSONCheckError()
parseReply()

But in this function, for some reasons, the last two steps were
swapped. This makes no sense.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor_json.c

index a48a2639652331967ced93b3e871fff09ca771ab..d5db60e749f4e1f3f6f17856f91fb474c2e68fc7 100644 (file)
@@ -3401,14 +3401,14 @@ qemuMonitorJSONQueryRxFilter(qemuMonitorPtr mon, const char *alias,
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
         goto cleanup;
 
+    if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+        goto cleanup;
+
     if (qemuMonitorJSONQueryRxFilterParse(reply, filter) < 0)
         goto cleanup;
 
     ret = 0;
  cleanup:
-    if (ret == 0)
-        ret = qemuMonitorJSONCheckError(cmd, reply);
-
     if (ret < 0) {
         virNetDevRxFilterFree(*filter);
         *filter = NULL;