]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: perf: Don't leak domain
authorPeter Krempa <pkrempa@redhat.com>
Thu, 21 Apr 2016 07:51:08 +0000 (09:51 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 21 Apr 2016 07:57:02 +0000 (09:57 +0200)
After failing to parse the perf event list, the code would return
failure without freeing the previously acquired object. Rearrange the
code to avoid the problem.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329046

tools/virsh-domain.c

index a1d4a75747457c3255d57cad6944a8676fa88d57..4a73a80c2eb258332fc66509e22c706fa2fb97d5 100644 (file)
@@ -8623,13 +8623,13 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
     if (live)
         flags |= VIR_DOMAIN_AFFECT_LIVE;
 
-    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
-        return false;
-
     if (vshCommandOptStringReq(ctl, cmd, "enable", &enable) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "disable", &disable) < 0)
         return false;
 
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+        return false;
+
     if (enable && virshParseEventStr(enable, true, &params,
                                      &nparams, &maxparams) < 0)
         goto cleanup;