[PATCH 7/9] conf: Fix memory leak in openvzReadFSConf

John Ferlan posted 9 patches 4 years, 5 months ago
[PATCH 7/9] conf: Fix memory leak in openvzReadFSConf
Posted by John Ferlan 4 years, 5 months ago
Since 1f5deed9, @veid_str has been leaked in the error path.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/openvz/openvz_conf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index c06bfa13e3..190c57b622 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -330,7 +330,7 @@ openvzReadFSConf(virDomainDefPtr def,
 {
     int ret;
     virDomainFSDefPtr fs = NULL;
-    char *veid_str = NULL;
+    g_autofree char *veid_str = NULL;
     char *temp = NULL;
     const char *param;
     unsigned long long barrier, limit;
@@ -365,8 +365,6 @@ openvzReadFSConf(virDomainDefPtr def,
         fs->type = VIR_DOMAIN_FS_TYPE_MOUNT;
         if (!(fs->src->path = virStringReplace(temp, "$VEID", veid_str)))
             goto error;
-
-        VIR_FREE(veid_str);
     }
 
     fs->dst = g_strdup("/");
-- 
2.25.4