]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
cmdDomIfAddr: Free @ip_addr_str
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 17 Mar 2015 16:34:22 +0000 (17:34 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 18 Mar 2015 08:13:53 +0000 (09:13 +0100)
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 <mprivozn@redhat.com>
tools/virsh-domain-monitor.c

index 07170760774cdc6b4258f3e8d38055d68b3b14cf..0eb1b624b2d91693a0dce5d0e095f024e5022a18 100644 (file)
@@ -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);
         }
     }