From 679fcfe96923231d065d3e98e0251f1c3282a971 Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Mon, 24 Feb 2020 01:46:14 -0500 Subject: [PATCH] conf: fix use after free MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Daniel P. Berrangé Signed-off-by: Ryan Moeller --- src/conf/virnetworkobj.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 299cdba52d..b2affaacd3 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1886,7 +1886,7 @@ virNetworkObjLoadAllPorts(virNetworkObjPtr net, } while ((rc = virDirRead(dh, &de, dir)) > 0) { - char *file = NULL; + g_autofree char *file = NULL; if (!virStringStripSuffix(de->d_name, ".xml")) continue; @@ -1894,9 +1894,6 @@ virNetworkObjLoadAllPorts(virNetworkObjPtr net, file = g_strdup_printf("%s/%s.xml", dir, de->d_name); portdef = virNetworkPortDefParseFile(file); - VIR_FREE(file); - file = NULL; - if (!portdef) { VIR_WARN("Cannot parse port %s", file); continue;