changeset 3949:33b9323388c5

[xemacs-hg @ 2007-05-12 10:59:15 by aidan] Zero out device modifier map after freeing it, X11, GTK.
author aidan
date Sat, 12 May 2007 10:59:17 +0000
parents adecfd791c9b
children 4cc3828e29bb
files src/ChangeLog src/event-Xt.c src/event-gtk.c
diffstat 3 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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  <kehoea@parhasard.net>
+
+	* 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  <stephen@xemacs.org>
 
 	* font-mgr.c (Qfontsetp): Remove unused declaration.
--- 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);
 
--- 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);