[PATCH] Fix memory leaks in audit & VirtualBox code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* src/util/virtaudit.c: Free audit string
* src/vbox/vbox_XPCOMCGlue.c: Free library name
---
 src/util/virtaudit.c       |    6 +++++-
 src/vbox/vbox_XPCOMCGlue.c |    1 +
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/util/virtaudit.c b/src/util/virtaudit.c
index b630fce..33be4d9 100644
--- a/src/util/virtaudit.c
+++ b/src/util/virtaudit.c
@@ -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
 }
diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
index 15a9622..d73e799 100644
--- a/src/vbox/vbox_XPCOMCGlue.c
+++ b/src/vbox/vbox_XPCOMCGlue.c
@@ -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 {
-- 
1.7.2.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]