[PATCH] om: Fix memory leaks on get_font_name error paths.

Ander Conselvan de Oliveira ander.conselvan-de-oliveira at nokia.com
Wed Apr 13 00:36:46 PDT 2011


Ops, forgot the

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan-de-oliveira at nokia.com>

On 04/13/2011 10:25 AM, Ander Conselvan de Oliveira wrote:
> While at it, remove unneeded check for NULL before Xfree.
> ---
>   modules/om/generic/omGeneric.c |   14 ++++++--------
>   1 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/modules/om/generic/omGeneric.c b/modules/om/generic/omGeneric.c
> index 8f02166..44143ac 100644
> --- a/modules/om/generic/omGeneric.c
> +++ b/modules/om/generic/omGeneric.c
> @@ -575,7 +575,7 @@ get_rotate_fontname(
>       }
> 
>       if(field_num<  CHARSET_ENCODING_FIELD)
> -	return NULL;
> +	goto free_pattern;
> 
>       /* Pixel Size field : fields[6] */
>       for(ptr = fields[PIXEL_SIZE_FIELD - 1] ; ptr&&  *ptr; ptr++) {
> @@ -584,9 +584,7 @@ get_rotate_fontname(
>   	        strcpy(pattern, font_name);
>   		return(pattern);
>   	    }
> -	    if(pattern)
> -		Xfree(pattern);
> -	    return NULL;
> +	    goto free_pattern;
>   	}
>       }
>       pixel_size = atoi(fields[PIXEL_SIZE_FIELD - 1]);
> @@ -605,11 +603,11 @@ get_rotate_fontname(
> 
>       /* Max XLFD length is 255 */
>       if (len>  XLFD_MAX_LEN)
> -	return NULL;
> +	goto free_pattern;
> 
>       rotate_font_ptr = (char *)Xmalloc(len + 1);
>       if(!rotate_font_ptr)
> -	return NULL;
> +	goto free_pattern;
> 
>       rotate_font_ptr[0] = '\0';
> 
> @@ -619,8 +617,8 @@ get_rotate_fontname(
>   	strcat(rotate_font_ptr, fields[field_num]);
>       }
> 
> -    if(pattern)
> -	Xfree(pattern);
> +free_pattern:
> +    Xfree(pattern);
> 
>       return rotate_font_ptr;
>   }



More information about the xorg-devel mailing list