xd->lock_interpretation = 0;
if (xd->x_modifier_keymap)
- XFreeModifiermap (xd->x_modifier_keymap);
+ {
+ XFreeModifiermap (xd->x_modifier_keymap);
+ /* Set it to NULL in case we receive two MappingModifier events in a
+ row, and the second is processed during some CHECK_QUITs within
+ x_reset_key_mapping. If that happens, XFreeModifierMap will be
+ called twice on the same map, and we crash. */
+ xd->x_modifier_keymap = NULL;
+ }
x_reset_key_mapping (d);