[patch] Fix memory leak in xf86LogInit()

Peter Hutterer mailinglists at who-t.net
Mon Feb 18 00:11:13 PST 2008


Arjan van de Ven wrote:
> 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
>  }
> [


thanks, pushed as 1bec6ad8977cefa49cc297a310f5eb0b7cd0b8bc.



More information about the xorg mailing list