]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
audit: fix memory leak without WITH_AUDIT
authorJán Tomko <jtomko@redhat.com>
Thu, 18 Sep 2014 10:08:37 +0000 (12:08 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 18 Sep 2014 12:49:01 +0000 (14:49 +0200)
Free str unconditionally since we allocate it without WITH_AUDIT
too.

src/util/viraudit.c

index d0ad9b9387a3ab7da3040943936a6d77dca019ea..23928fda9a2496f496a839e941f2c29b514f320f 100644 (file)
@@ -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)