[PATCH v2] Xext: Fix a memory leak on GE client disconnect.

Peter Hutterer peter.hutterer at who-t.net
Wed Nov 18 18:20:13 PST 2009


On Tue, Nov 17, 2009 at 05:13:43PM +0200, Rami Ylimaki wrote:
> Add a call to dixRequestPrivate to inform dixFreePrivates that memory
> allocated in GEClientCallback should be released when client
> disconnects. Otherwise there is a leak of sizeof(GEClientInfoRec) for
> every client connect/disconnect.
> 
> Also remove the explicit allocation and let GEGetClient /
> dixLookupPrivate do it. This makes GEClientCallback similar to the
> other extension callbacks.
> 
> Signed-off-by: Rami Ylimaki <ext-rami.ylimaki at nokia.com>
> ---
> Modified according to feedback from Oliver McFadden.
> 
>  Xext/geext.c |    9 +++------
>  1 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/Xext/geext.c b/Xext/geext.c
> index 6fad4ae..2ba0ca8 100644
> --- a/Xext/geext.c
> +++ b/Xext/geext.c
> @@ -168,12 +168,6 @@ GEClientCallback(CallbackListPtr *list,
>      ClientPtr		pClient = clientinfo->client;
>      GEClientInfoPtr     pGEClient = GEGetClient(pClient);
>  
> -    if (pGEClient == NULL)
> -    {
> -        pGEClient = xcalloc(1, sizeof(GEClientInfoRec));
> -        dixSetPrivate(&pClient->devPrivates, GEClientPrivateKey, pGEClient);
> -    }
> -
>      pGEClient->major_version = 0;
>      pGEClient->minor_version = 0;
>  }
> @@ -222,6 +216,9 @@ GEExtensionInit(void)
>  {
>      ExtensionEntry *extEntry;
>  
> +    if (!dixRequestPrivate(GEClientPrivateKey, sizeof(GEClientInfoRec)))
> +        FatalError("GEExtensionInit: GE private request failed.\n");
> +
>      if(!AddCallback(&ClientStateCallback, GEClientCallback, 0))
>      {
>          FatalError("GEExtensionInit: register client callback failed.\n");
> -- 
> 1.6.0.4

Thanks, merged this into my tree, I'll do a bit of basic testing and it'll
be in my next pull request.
 
Cheers,
  Peter


More information about the xorg-devel mailing list