From e09d7d080d951a66551ef5cca2ea50932b82a27c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 19 Dec 2019 09:48:05 +0100 Subject: [PATCH] vbox: Use g_autofree in vboxDomainScreenshot() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also fixes a cacheDir's leak when g_mkstep_full() fails. Signed-off-by: Fabiano Fidêncio Reviewed-by: Ján Tomko --- src/vbox/vbox_common.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 5957ae52c4..586937fa19 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -7341,8 +7341,8 @@ vboxDomainScreenshot(virDomainPtr dom, vboxIID iid; IMachine *machine = NULL; nsresult rc; - char *tmp; - char *cacheDir; + g_autofree char *tmp = NULL; + g_autofree char *cacheDir = NULL; int tmp_fd = -1; unsigned int max_screen; bool privileged = geteuid() == 0; @@ -7383,7 +7383,6 @@ vboxDomainScreenshot(virDomainPtr dom, if ((tmp_fd = g_mkstemp_full(tmp, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR)) == -1) { virReportSystemError(errno, _("g_mkstemp(\"%s\") failed"), tmp); - VIR_FREE(tmp); VBOX_RELEASE(machine); return NULL; } @@ -7454,8 +7453,6 @@ vboxDomainScreenshot(virDomainPtr dom, VIR_FORCE_CLOSE(tmp_fd); unlink(tmp); - VIR_FREE(tmp); - VIR_FREE(cacheDir); VBOX_RELEASE(machine); vboxIIDUnalloc(&iid); return ret;