From: Ján Tomko Date: Thu, 18 Sep 2014 10:08:37 +0000 (+0200) Subject: audit: fix memory leak without WITH_AUDIT X-Git-Tag: v1.2.9-rc1~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1d55105a4bf7643216c33561d5d633dd7890902;p=thirdparty%2Flibvirt.git audit: fix memory leak without WITH_AUDIT Free str unconditionally since we allocate it without WITH_AUDIT too. --- diff --git a/src/util/viraudit.c b/src/util/viraudit.c index d0ad9b9387..23928fda9a 100644 --- a/src/util/viraudit.c +++ b/src/util/viraudit.c @@ -115,12 +115,7 @@ void virAuditSend(virLogSourcePtr source, } #if WITH_AUDIT - if (auditfd < 0) { - VIR_FREE(str); - return; - } - - if (str) { + if (str && auditfd >= 0) { static const int record_types[] = { [VIR_AUDIT_RECORD_MACHINE_CONTROL] = AUDIT_VIRT_CONTROL, [VIR_AUDIT_RECORD_MACHINE_ID] = AUDIT_VIRT_MACHINE_ID, @@ -135,9 +130,9 @@ void virAuditSend(virLogSourcePtr source, VIR_WARN("Failed to send audit message %s: %s", NULLSTR(str), virStrerror(errno, ebuf, sizeof(ebuf))); } - VIR_FREE(str); } #endif + VIR_FREE(str); } void virAuditClose(void)