From: John Ferlan Date: Tue, 16 Jun 2020 12:07:07 +0000 (-0400) Subject: conf: Fix memory leak in openvzWriteConfigParam X-Git-Tag: v6.5.0-rc1~168 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd0e292992a2a6f2eaf58d58285e15a563a6afe1;p=thirdparty%2Flibvirt.git conf: Fix memory leak in openvzWriteConfigParam Since 60623a7c, @temp_file was not properly free'd on the non error path. Found by Coverity. Signed-off-by: John Ferlan Reviewed-by: Peter Krempa --- 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; }