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

Rami Ylimaki ext-rami.ylimaki at nokia.com
Thu Nov 5 07:29:13 PST 2009


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>
---
Please note that I have only tested a modified version of this patch
with 1.6.99.1. However, this fix seems to be valid for master
also. The only difference between the tested patch and this patch is
that this one has been modified to apply cleanly on master.

 Xext/geext.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/Xext/geext.c b/Xext/geext.c
index 6fad4ae..0c7f59d 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("Cannot request private for GE.\n");
+
     if(!AddCallback(&ClientStateCallback, GEClientCallback, 0))
     {
         FatalError("GEExtensionInit: register client callback failed.\n");
-- 
1.6.0.4



More information about the xorg-devel mailing list