From: Michal Privoznik Date: Tue, 17 Mar 2015 16:34:22 +0000 (+0100) Subject: cmdDomIfAddr: Free @ip_addr_str X-Git-Tag: v1.2.14-rc1~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0aff8fa8299fa3f3066d05c70eb3cb6a72039cc7;p=thirdparty%2Flibvirt.git cmdDomIfAddr: Free @ip_addr_str The variable holds formatted suffix to each line printed out (address type, address and prefix). However, the variable is never freed. At the same time, honour fact, that data held in the variable is not constant. Signed-off-by: Michal Privoznik --- diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 0717076077..0eb1b624b2 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -2269,7 +2269,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) for (i = 0; i < ifaces_count; i++) { virDomainInterfacePtr iface = ifaces[i]; - const char *ip_addr_str = NULL; + char *ip_addr_str = NULL; const char *type = NULL; if (interface && STRNEQ(interface, iface->name)) @@ -2308,7 +2308,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) ip_addr_str = virBufferContentAndReset(&buf); if (!ip_addr_str) - ip_addr_str = ""; + ip_addr_str = vshStrdup(ctl, ""); /* Don't repeat interface name */ if (full || !j) @@ -2320,6 +2320,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) "-", "-", ip_addr_str); virBufferFreeAndReset(&buf); + VIR_FREE(ip_addr_str); } }