From 27616d1c02b697df151ed8c9116e46e440549036 Mon Sep 17 00:00:00 2001
From: Michal Privoznik <mprivozn@redhat.com>
Date: Tue, 9 Jul 2019 16:46:31 +0200
Subject: [PATCH] virnetworkobj: Free retval of virNetworkObjGetPortStatusDir()

The virNetworkObjGetPortStatusDir() function allocates a memory
to construct a path. None of the callers free it leading to a
memleak.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
(cherry-picked from commit 37d8d6b98d2046c023935a6c9723defcdbf6c069)
Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
---
 src/conf/virnetworkobj.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 12cefeb..45726e4 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1627,7 +1627,7 @@ virNetworkObjAddPort(virNetworkObjPtr net,
 {
     int ret = -1;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
-    char *dir = NULL;
+    VIR_AUTOFREE(char *) dir = NULL;
 
     virUUIDFormat(portdef->uuid, uuidstr);
 
@@ -1717,7 +1717,7 @@ int
 virNetworkObjDeleteAllPorts(virNetworkObjPtr net,
                             const char *stateDir)
 {
-    char *dir;
+    VIR_AUTOFREE(char *) dir = NULL;
     DIR *dh = NULL;
     struct dirent *de;
     int rc;
@@ -1843,7 +1843,7 @@ static int
 virNetworkObjLoadAllPorts(virNetworkObjPtr net,
                           const char *stateDir)
 {
-    char *dir;
+    VIR_AUTOFREE(char *) dir = NULL;
     DIR *dh = NULL;
     struct dirent *de;
     int ret = -1;
-- 
2.19.1

