[PATCH] Don't leak default font path when appending built-ins

Peter Hutterer peter.hutterer at who-t.net
Tue Mar 31 16:58:35 PDT 2009


On Tue, Mar 31, 2009 at 11:23:24AM -0700, Alan Coopersmith wrote:
> Signed-off-by: Alan Coopersmith <alan.coopersmith at sun.com>
> ---
>  hw/xfree86/common/xf86Config.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
> index b9ab11a..39b1664 100644
> --- a/hw/xfree86/common/xf86Config.c
> +++ b/hw/xfree86/common/xf86Config.c
> @@ -613,7 +613,11 @@ configFiles(XF86ConfFilesPtr fileconf)
>  	!((start == temp_path || start[-1] == ',') && (!*end || *end == ','))) {
>  	defaultFontPath = Xprintf("%s%sbuilt-ins",
>  				  temp_path, *temp_path ? "," : "");
> -	must_copy = FALSE;
> +	if (must_copy == FALSE) {
> +	    xfree(temp_path);
> +	} else {
> +	    must_copy = FALSE;
> +	}
>      }
>      /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */
>      temp_path = must_copy ? xnfstrdup(defaultFontPath) : defaultFontPath;
> -- 
> 1.5.6.5

There's a code path (if defaultFontPath is NULL) where temp_path is assigned
to an empty string (line 607). With this patch, the server would then try to
free this string. Are there some surrounding conditions that I'm missing that
guarantee that path isn't triggered?

Also, I'm not a big fan of (foo == FALSE) conditions.

Cheers,
  Peter


More information about the xorg-devel mailing list