]> xenbits.xensource.com Git - libvirt.git/commitdiff
nwfilter: Fix memory leak in virNWFilterIPAddrMapAddIPAddr
authorZhiPeng Lu <lu.zhipeng@zte.com.cn>
Wed, 27 Sep 2017 08:53:50 +0000 (16:53 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 27 Sep 2017 11:23:44 +0000 (07:23 -0400)
If virNWFilterHashTablePut fails, then the @val was leaked.

Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn>
src/conf/nwfilter_ipaddrmap.c

index 446f3de4f903c8b2a0fc7663fd4a8bd3ee596f91..9c8584ce27c953d535eb005682014dcb5f7a5474 100644 (file)
@@ -61,6 +61,8 @@ virNWFilterIPAddrMapAddIPAddr(const char *ifname, char *addr)
         if (!val)
             goto cleanup;
         ret = virNWFilterHashTablePut(ipAddressMap, ifname, val);
+        if (ret < 0)
+            virNWFilterVarValueFree(val);
         goto cleanup;
     } else {
         if (virNWFilterVarValueAddValue(val, addr) < 0)