[PATCH 6/9] conf: Fix memory leak in openvzWriteConfigParam

John Ferlan jferlan at redhat.com
Tue Jun 16 12:07:07 UTC 2020


Since 60623a7c, @temp_file was not properly free'd on the non error path.

Found by Coverity.

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

diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 78547b8b28..c06bfa13e3 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -616,7 +616,7 @@ int openvzLoadDomains(struct openvz_driver *driver)
 static int
 openvzWriteConfigParam(const char * conf_file, const char *param, const char *value)
 {
-    char * temp_file = NULL;
+    g_autofree char *temp_file = NULL;
     int temp_fd = -1;
     FILE *fp;
     char *line = NULL;
@@ -666,7 +666,6 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
     VIR_FORCE_CLOSE(temp_fd);
     if (temp_file)
         unlink(temp_file);
-    VIR_FREE(temp_file);
     return -1;
 }
 
-- 
2.25.4




More information about the libvir-list mailing list