mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
virsh: plug memory leaks on failure path
Leaks are introduced in commit 1cf0e3d and fe383bb. Fixing memory leaks, in addition, the patch also fixes a potential missing return value issue in 'if (from)' statement, without the fixing, although the programming met a error, the subsequent codes will be executed continually. * tools/virsh.c (cmdSnapshotList): fix memory leaks and missing return value. * How to reproduce? % virsh snapshot-list <domain> --parent --roots % virsh snapshot-list <domain> --parent --tree % virsh snapshot-list <domain> --roots --tree actual result: error: --parent and --roots are mutually exclusive error: Failed to disconnect from the hypervisor, 1 leaked reference(s) error: --parent and --tree are mutually exclusive error: Failed to disconnect from the hypervisor, 1 leaked reference(s) error: --roots and --tree are mutually exclusive error: Failed to disconnect from the hypervisor, 1 leaked reference(s) % virsh snapshot-create-as <domain> --name "hello" % virsh snapshot-create-as <domain> --name "libvirt" % virsh snapshot-list <domain> --roots --from "hello" actual result: error: --roots and --from are mutually exclusive Name Creation Time State ------------------------------------------------------------ libvirt 2012-03-28 13:46:51 +0800 running Signed-off-by: Alex Jia <ajia@redhat.com>
This commit is contained in:
parent
1aeb3d9e7f
commit
03ca3317a6
@ -16357,23 +16357,24 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
|
||||
if (vshCommandOptBool(cmd, "roots")) {
|
||||
vshError(ctl, "%s",
|
||||
_("--parent and --roots are mutually exclusive"));
|
||||
return false;
|
||||
goto cleanup;
|
||||
}
|
||||
if (tree) {
|
||||
vshError(ctl, "%s",
|
||||
_("--parent and --tree are mutually exclusive"));
|
||||
return false;
|
||||
goto cleanup;
|
||||
}
|
||||
parent_filter = 1;
|
||||
} else if (vshCommandOptBool(cmd, "roots")) {
|
||||
if (tree) {
|
||||
vshError(ctl, "%s",
|
||||
_("--roots and --tree are mutually exclusive"));
|
||||
return false;
|
||||
goto cleanup;
|
||||
}
|
||||
if (from) {
|
||||
vshError(ctl, "%s",
|
||||
_("--roots and --from are mutually exclusive"));
|
||||
goto cleanup;
|
||||
}
|
||||
flags |= VIR_DOMAIN_SNAPSHOT_LIST_ROOTS;
|
||||
}
|
||||
@ -16381,7 +16382,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
|
||||
if (tree) {
|
||||
vshError(ctl, "%s",
|
||||
_("--leaves and --tree are mutually exclusive"));
|
||||
return false;
|
||||
goto cleanup;
|
||||
}
|
||||
flags |= VIR_DOMAIN_SNAPSHOT_LIST_LEAVES;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user