]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix memory leaks in audit & VirtualBox code
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 24 Nov 2010 11:49:40 +0000 (11:49 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 29 Nov 2010 15:17:16 +0000 (15:17 +0000)
* src/util/virtaudit.c: Free audit string
* src/vbox/vbox_XPCOMCGlue.c: Free library name

src/util/virtaudit.c
src/vbox/vbox_XPCOMCGlue.c

index b630fcec1a13f6324266a4b92f8de482cf237c8f..33be4d967693972ed4e901af504117534fbfe176 100644 (file)
@@ -32,6 +32,7 @@
 #include "virtaudit.h"
 #include "util.h"
 #include "files.h"
+#include "memory.h"
 
 /* Provide the macros in case the header file is old.
    FIXME: should be removed. */
@@ -110,8 +111,10 @@ void virAuditSend(const char *file ATTRIBUTE_UNUSED, const char *func,
     }
 
 #if HAVE_AUDIT
-    if (auditfd < 0)
+    if (auditfd < 0) {
+        VIR_FREE(str);
         return;
+    }
 
     if (str) {
         static const int record_types[] = {
@@ -128,6 +131,7 @@ void virAuditSend(const char *file ATTRIBUTE_UNUSED, const char *func,
             VIR_WARN("Failed to send audit message %s: %s",
                      NULLSTR(str), virStrerror(errno, ebuf, sizeof ebuf));
         }
+        VIR_FREE(str);
     }
 #endif
 }
index 15a9622d957793fb20ab9f93bce61ea51a133074..d73e799c7be59ff1c9898f414d25f59d71dcb8c3 100644 (file)
@@ -98,6 +98,7 @@ static int tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing)
                 VIR_ERROR(_("Libaray '%s' doesn't exist"), name);
             }
 
+            VIR_FREE(name);
             return -1;
         }
     } else {