From: Shi Lei Date: Wed, 16 Dec 2020 06:01:06 +0000 (+0800) Subject: lxc: fix a memory leak X-Git-Tag: v7.0.0-rc1~185 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecfc2d5f43a790be636f3af7c112ae2e45b29c6b;p=thirdparty%2Flibvirt.git lxc: fix a memory leak In virLXCProcessSetupInterfaceTap, containerVeth needs to be freed on failure. Signed-off-by: Shi Lei Reviewed-by: Laine Stump --- diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 85d0287a35..0f7c929535 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -303,7 +303,7 @@ virLXCProcessSetupInterfaceTap(virDomainDefPtr vm, const char *brname) { char *parentVeth; - char *containerVeth = NULL; + g_autofree char *containerVeth = NULL; const virNetDevVPortProfile *vport = virDomainNetGetActualVirtPortProfile(net); VIR_DEBUG("calling vethCreate()"); @@ -357,7 +357,7 @@ virLXCProcessSetupInterfaceTap(virDomainDefPtr vm, virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net, false) < 0) return NULL; - return containerVeth; + return g_steal_pointer(&containerVeth); }