From 72e3e6f4a7690f70a6b5f7689633cdea859535e1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 23 Aug 2010 13:20:09 +1000 Subject: [PATCH] dix: fix crash when removing devices on a buttonless MD pointer (#29669) If the master does not have a button class, recalculating the number of buttons required for this master dereferences a NULL pointer. Guard against this, if the master pointer doesn't have a button class, it doesn't need to update it's number of buttons. Reproducible: Two devices on the same master, device NB with axes but no buttons, device A+B with axes and button . If NB was the last one to send an event through the master when A+B is removed from the server, master->button is NULL and leads to the above NULL-pointer dereference. X.Org Bug 29669 Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard (cherry picked from commit ff055506f0cbb852bed17acb9f9bbf1d715a854e) --- dix/devices.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/devices.c b/dix/devices.c index 2e65a041d..0bd9b75e6 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -2336,7 +2336,7 @@ RecalculateMasterButtons(DeviceIntPtr slave) maxbuttons = max(maxbuttons, dev->button->numButtons); } - if (master->button->numButtons != maxbuttons) + if (master->button && master->button->numButtons != maxbuttons) { int i; DeviceChangedEvent event;