[PATCH libX11 4/5] fix memleak in error path

Eric Engestrom eric.engestrom at imgtec.com
Tue Apr 26 14:47:29 UTC 2016


On Tue, Apr 26, 2016 at 04:29:41PM +0200, walter harms wrote:
> 
> 
> free all memory on error
> 
> Signed-off-by: walter harms <wharms at bfs.de>
> 
> 
> ---
>  src/xlibi18n/lcPublic.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/xlibi18n/lcPublic.c b/src/xlibi18n/lcPublic.c
> index 98a7435..08122b9 100644
> --- a/src/xlibi18n/lcPublic.c
> +++ b/src/xlibi18n/lcPublic.c
> @@ -78,7 +78,7 @@ create(
>      XLCdMethods methods)
>  {
>      XLCd lcd;
> -    XLCdPublicMethods new;
> +    XLCdPublicMethods new=NULL;

This is unnecessary: `new` will be overwritten a few lines below, or
discarded as a local var if we return before that.

> 
>      lcd = Xcalloc(1, sizeof(XLCdRec));
>      if (lcd == NULL)
> @@ -97,6 +97,7 @@ create(
>      return lcd;
> 
>  err:
> +    Xfree(lcd->core);

This bit is right though. Feel free to cleanup this patch & re-send.

>      Xfree(lcd);
>      return (XLCd) NULL;
>  }
> -- 
> 2.1.4


More information about the xorg-devel mailing list