]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Fix memory leak in openvzWriteConfigParam
authorJohn Ferlan <jferlan@redhat.com>
Tue, 16 Jun 2020 12:07:07 +0000 (08:07 -0400)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 16 Jun 2020 13:01:06 +0000 (15:01 +0200)
Since 60623a7c, @temp_file was not properly free'd on the non error path.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/openvz/openvz_conf.c

index 78547b8b28c2bace99ea32cb72ad08cf6e4e9e70..c06bfa13e3cc350cbf3a3accd82883a68d977a6d 100644 (file)
@@ -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;
 }