summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPeter Krempa <pkrempa@redhat.com>2014-07-21 09:53:17 +0200
committerPeter Krempa <pkrempa@redhat.com>2014-07-21 15:20:59 +0200
commitba2b4da02d884acc6ee80057b8675e8e83901be0 (patch)
tree2254f60a5b927e85d10d58f4c3a0c7d5d5644df0 /examples
parentabab113bd237c4700190db32e01db352569d9b3f (diff)
downloadlibvirt-ba2b4da02d884acc6ee80057b8675e8e83901be0.tar.gz
examples: domtop: Avoid leaking memory
Use the virTypedParamsFree unconditionally as it handles NULL well and has the benefit of freeing a typed parameter array even if it wasn't yet assigned, but only allocated.
Diffstat (limited to 'examples')
-rw-r--r--examples/domtop/domtop.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
index 7661057b12..4ac7889221 100644
--- a/examples/domtop/domtop.c
+++ b/examples/domtop/domtop.c
@@ -334,12 +334,8 @@ do_top(virConnectPtr conn,
ret = 0;
cleanup:
- if (max_id > 0) {
- if (now_nparams > 0)
- virTypedParamsFree(now_params, now_nparams * max_id);
- if (then_nparams > 0)
- virTypedParamsFree(then_params, then_nparams * max_id);
- }
+ virTypedParamsFree(now_params, now_nparams * max_id);
+ virTypedParamsFree(then_params, then_nparams * max_id);
if (dom)
virDomainFree(dom);
return ret;