# HG changeset patch # User aidan # Date 1178967557 0 # Node ID 33b9323388c58001527ddeaa3dad5e39985052d9 # Parent adecfd791c9b2857f53b7db1340c77a267696077 [xemacs-hg @ 2007-05-12 10:59:15 by aidan] Zero out device modifier map after freeing it, X11, GTK. diff -r adecfd791c9b -r 33b9323388c5 src/ChangeLog --- a/src/ChangeLog Sat May 12 10:17:09 2007 +0000 +++ b/src/ChangeLog Sat May 12 10:59:17 2007 +0000 @@ -1,3 +1,10 @@ +2007-05-12 Aidan Kehoe + + * event-Xt.c (x_reset_modifier_mapping): + * event-gtk.c (gtk_reset_modifier_mapping): + Zero out the device's modifier map once we've freed it, to prevent + a double free on a re-entrant call. + 2007-05-01 Stephen J. Turnbull * font-mgr.c (Qfontsetp): Remove unused declaration. diff -r adecfd791c9b -r 33b9323388c5 src/event-Xt.c --- a/src/event-Xt.c Sat May 12 10:17:09 2007 +0000 +++ b/src/event-Xt.c Sat May 12 10:59:17 2007 +0000 @@ -323,7 +323,14 @@ 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); diff -r adecfd791c9b -r 33b9323388c5 src/event-gtk.c --- a/src/event-gtk.c Sat May 12 10:17:09 2007 +0000 +++ b/src/event-gtk.c Sat May 12 10:59:17 2007 +0000 @@ -1863,7 +1863,14 @@ xd->lock_interpretation = 0; if (map) - XFreeModifiermap (map); + { + 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; + } gtk_reset_key_mapping (d);