768311
From 11eea736f44a236dde884b52ad51cb5d1271b7a5 Mon Sep 17 00:00:00 2001
768311
From: Peter Hutterer <peter.hutterer@who-t.net>
768311
Date: Wed, 13 Jan 2010 15:03:45 +1000
768311
Subject: [PATCH] Xi: reset the sli pointers after copying device classes. (#25640)
768311
768311
If the indicator flags have the XkbSLI_IsDefault bit set, the indicator map
768311
and names aren't their own bit of memory but rather point into the
768311
device->key->xkbInfo->desc structure. XkbCopySrvLedInfo knows about this and
768311
leaves the pointers alone.
768311
768311
When copying the classes from the slave to the master, these pointers are
768311
copied and still point to the dev->key class of the slave device. If the
768311
slave device is removed, the memory becomes invalid and a call to modify
768311
this data (e.g. XkbSetIndicators) may cause a deadlock.
768311
768311
The copying of dev->key relies on dev->kbdfeed to be already set up. Hence
768311
the pointers need to be reset once _both_ kbdfeed and key have been copied
768311
into the master device.
768311
768311
X.Org Bug 25640 <http: bugs.freedesktop.org="" show_bug.cgi?id="25640">
768311
Fedora Bug 540584 <https: bugzilla.redhat.com="" show_bug.cgi?id="540584">
768311
---
768311
 Xi/exevents.c |   20 ++++++++++++++++++++
768311
 1 files changed, 20 insertions(+), 0 deletions(-)
768311
768311
diff --git a/Xi/exevents.c b/Xi/exevents.c
768311
index cb2452b..ee32ba8 100644
768311
--- a/Xi/exevents.c
768311
+++ b/Xi/exevents.c
768311
@@ -444,6 +444,26 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
768311
         to->key      = NULL;
768311
     }
768311
 
768311
+    /* If a SrvLedInfoPtr's flags are XkbSLI_IsDefault, the names and maps
768311
+     * pointer point into the xkbInfo->desc struct.  XkbCopySrvLedInfo
768311
+     * didn't update the pointers so we need to do it manually here.
768311
+     */
768311
+    if (to->kbdfeed)
768311
+    {
768311
+        KbdFeedbackPtr k;
768311
+
768311
+        for (k = to->kbdfeed; k; k = k->next)
768311
+        {
768311
+            if (!k->xkb_sli)
768311
+                continue;
768311
+            if (k->xkb_sli->flags & XkbSLI_IsDefault)
768311
+            {
768311
+                k->xkb_sli->names = to->key->xkbInfo->desc->names->indicators;
768311
+                k->xkb_sli->maps = to->key->xkbInfo->desc->indicators->maps;
768311
+            }
768311
+        }
768311
+    }
768311
+
768311
     /* We can't just copy over the focus class. When an app sets the focus,
768311
      * it'll do so on the master device. Copying the SDs focus means losing
768311
      * the focus.
768311
-- 
768311
1.6.6
768311