[PATCH 4/9] dix: only allocate unused classes for master devices
Peter Hutterer
peter.hutterer at who-t.net
Mon Feb 27 16:41:01 PST 2012
Slave devices don't need these and the matching code in CloseDevice() has a
IsMaster() condition on freeing these, causing a leak.
==16111== 384 bytes in 4 blocks are definitely lost in loss record 72 of 105
==16111== at 0x4C28BB4: calloc (vg_replace_malloc.c:467)
==16111== by 0x42AEE2: AllocDevicePair (devices.c:2707)
==16111== by 0x4BAA27: AllocXTestDevice (xtest.c:617)
==16111== by 0x4BA89A: InitXTestDevices (xtest.c:570)
==16111== by 0x425F5E: InitCoreDevices (devices.c:690)
==16111== by 0x5ACB2D: main (main.c:257)
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
dix/devices.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dix/devices.c b/dix/devices.c
index 7478ad6..537f410 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2703,8 +2703,11 @@ AllocDevicePair (ClientPtr client, const char* name,
keyboard->type = (master) ? MASTER_KEYBOARD : SLAVE;
/* The ClassesRec stores the device classes currently not used. */
- pointer->unused_classes = calloc(1, sizeof(ClassesRec));
- keyboard->unused_classes = calloc(1, sizeof(ClassesRec));
+ if (IsMaster(pointer))
+ {
+ pointer->unused_classes = calloc(1, sizeof(ClassesRec));
+ keyboard->unused_classes = calloc(1, sizeof(ClassesRec));
+ }
*ptr = pointer;
*keybd = keyboard;
--
1.7.7.6
More information about the xorg-devel
mailing list