[patch] Fix memory leak in xf86LogInit()

Arjan van de Ven arjan at infradead.org
Tue Feb 12 10:50:56 PST 2008


xf86LogInit alloced a piece of memory, stores it in lf ... and then calls effectively strdup()
on it. Sadly it then forgot to free the original.. this patch fixes that.


--- xserver/hw/xfree86/common/xf86Helper.c~	2008-02-11 11:43:51.000000000 +0100
+++ xserver/hw/xfree86/common/xf86Helper.c	2008-02-11 11:43:51.000000000 +0100
@@ -1406,7 +1406,7 @@ xf86ErrorF(const char *format, ...)
 void
 xf86LogInit()
 {
-    char *lf;
+    char *lf = NULL;
 
 #define LOGSUFFIX ".log"
 #define LOGOLDSUFFIX ".old"
@@ -1428,6 +1428,8 @@ xf86LogInit()
     xf86SetVerbosity(xf86Verbose);
     xf86SetLogVerbosity(xf86LogVerbose);
 
+    free(lf);
+
 #undef LOGSUFFIX
 #undef LOGOLDSUFFIX
 }
[
-- 
If you want to reach me at my work email, use arjan at linux.intel.com
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org



More information about the xorg mailing list