xserver: Branch 'master' - 3 commits

Peter Hutterer whot at kemper.freedesktop.org
Mon Feb 18 00:11:25 PST 2008


 hw/xfree86/common/xf86Helper.c |    4 +++-
 hw/xfree86/common/xf86Init.c   |    7 ++++++-
 hw/xfree86/loader/loadmod.c    |    1 +
 3 files changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 3abce3ea2b1f43bd111664d4a57e5ccd282acab0
Author: Arjan van de Ven <arjan at infradead.org>
Date:   Mon Feb 18 18:13:10 2008 +1030

    xfree86: plug a memory leak in xf86LoadModules.
    
    LoadModule() returns the only reference to a fresh piece of memory (a
    ModuleDescPtr). Sadly, xf86LoadModules dropped the return value on the floor
    leaking memory for each module it loaded.
    
    Signed-off-by: Peter Hutterer <peter at cs.unisa.edu.au>

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 41cf1d1..0d90b9d 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1922,6 +1922,7 @@ xf86LoadModules(char **list, pointer *optlist)
     int i;
     char *name;
     Bool failed = FALSE;
+    ModuleDescPtr desc;
 
     if (!list)
 	return TRUE;
@@ -1945,11 +1946,15 @@ xf86LoadModules(char **list, pointer *optlist)
 	else
 	    opt = NULL;
 
-        if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
+	desc = LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj,
+		&errmin);
+	if (!desc) {
 	    LoaderErrorMsg(NULL, name, errmaj, errmin);
 	    failed = TRUE;
 	}
 	xfree(name);
+	xfree(desc->name);
+	xfree(desc);
     }
     return !failed;
 }
commit 6dc71f6b2c7ff49adb504426b4cd206e4745e1e3
Author: Arjan van de Ven <arjan at infradead.org>
Date:   Mon Feb 18 17:52:37 2008 +1030

    xfree86: plug memory leak in InitPathList.
    
    All the failure paths were very diligent in freeing the "fullpath" temporary
    string, but the success case was not. All the content only got strdup()d, so
    it's not live memory anymore.
    
    Signed-off-by: Peter Hutterer <peter at cs.unisa.edu.au>

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 650dcf3..7f3bbe4 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -177,6 +177,7 @@ InitPathList(const char *path)
     }
     if (list)
 	list[n] = NULL;
+    xfree(fullpath);
     return list;
 }
 
commit 1bec6ad8977cefa49cc297a310f5eb0b7cd0b8bc
Author: Arjan van de Ven <arjan at infradead.org>
Date:   Mon Feb 18 17:46:04 2008 +1030

    xfree86: plug memory leak in xf86LogInit()
    
    xf86LogInit allocates a piece of memory, stores it in lf. LogInit() will then
    effectively strdup it, but lf is never freed again.
    
    Signed-off-by: Peter Hutterer <peter at cs.unisa.edu.au>

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 1368d04..0d2471a 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1353,7 +1353,7 @@ xf86ErrorF(const char *format, ...)
 void
 xf86LogInit()
 {
-    char *lf;
+    char *lf = NULL;
 
 #define LOGSUFFIX ".log"
 #define LOGOLDSUFFIX ".old"
@@ -1377,6 +1377,8 @@ xf86LogInit()
 
 #undef LOGSUFFIX
 #undef LOGOLDSUFFIX
+
+    free(lf);
 }
 
 void


More information about the xorg-commit mailing list