[patch] fix another module loader memory leak

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


Arjan van de Ven wrote:
> 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.
> 
> --- hw/xfree86/common/xf86Init.c~	2008-02-11 12:08:38.000000000 +0100
> +++ hw/xfree86/common/xf86Init.c	2008-02-11 12:08:38.000000000 +0100
> @@ -1820,6 +1820,7 @@ xf86LoadModules(char **list, pointer *op
>      int i;
>      char *name;
>      Bool failed = FALSE;
> +    ModuleDescPtr *desc;
>  
>      if (!list)
>  	return TRUE;
> @@ -1842,11 +1843,15 @@ xf86LoadModules(char **list, pointer *op
>  	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);
> +	TestFree(desc->name);
> +	TestFree(desc->filename);
> +	xfree(desc);
>      }
>      return !failed;
>  }
> 

thanks.  pushed as 3abce3ea2b1f43bd111664d4a57e5ccd282acab0.
(this patch required some minor modifications to work with current git 
master)




More information about the xorg mailing list