From: Radoslaw Jablonski Date: Tue, 27 Mar 2018 14:59:13 +0000 (+0100) Subject: virt: Fix memory leak when using libvirt <= 1.0 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a3c8ee7061774b1324c313c7b4abbe6fc5680eec;p=collectd.git virt: Fix memory leak when using libvirt <= 1.0 Cleanup was missing for libvirt-allocated virDomainPtr. Change-Id: Ied152e9e4084ee9e25b7357e648a6aac8778d09b Signed-off-by: Radoslaw Jablonski --- diff --git a/src/virt.c b/src/virt.c index 4dc8645d..99483c47 100644 --- a/src/virt.c +++ b/src/virt.c @@ -1941,14 +1941,15 @@ static int persistent_domains_state_notification(void) { continue; } status = virDomainGetInfo(dom, &info); - if (status != 0) { + if (status == 0) + /* virDomainGetState is not available. Submit 0, which corresponds to + * unknown reason. */ + domain_state_submit_notif(dom, info.state, 0); + else ERROR(PLUGIN_NAME " plugin: virDomainGetInfo failed with status %i.", status); - continue; - } - /* virDomainGetState is not available. Submit 0, which corresponds to - * unknown reason. */ - domain_state_submit_notif(dom, info.state, 0); + + virDomainFree(dom); } sfree(domids); }