From f4f916a9e35d50fe423443e95ca02b28fb2d0e0b Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 21 Apr 2016 09:51:08 +0200 Subject: [PATCH] virsh: perf: Don't leak domain 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a1d4a75747..4a73a80c2e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -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, ¶ms, &nparams, &maxparams) < 0) goto cleanup;