]> xenbits.xensource.com Git - libvirt.git/commit
virsh: plug memory leaks on failure path
authorAlex Jia <ajia@redhat.com>
Wed, 28 Mar 2012 08:15:49 +0000 (16:15 +0800)
committerAlex Jia <ajia@redhat.com>
Wed, 28 Mar 2012 15:05:08 +0000 (23:05 +0800)
commit03ca3317a66b7ae5a1a6323487cad99b506cb714
tree77df2fb1fcbce8ef38cdfcf18ed337c6ea19daac
parent1aeb3d9e7f3a967f7d5e59f852e804aef0786f6c
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>
tools/virsh.c