[COMMIT] Zero out device modifier map after freeing it, X11, GTK

Aidan Kehoe kehoea at parhasard.net
Sat May 12 07:12:02 EDT 2007


 Ar an dara lá déag de mí Bealtaine, scríobh Aidan Kehoe: 

 > I’ll commit the change anyway; there’s no reason to keep a pointer to the
 > modifier map once it’s been freed. 

APPROVE COMMIT

NOTE: This patch has been committed.

src/ChangeLog addition:

2007-05-12  Aidan Kehoe  <kehoea at 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. 


XEmacs Trunk source patch:
Diff command:   cvs -q diff -Nu
Files affected: src/event-gtk.c
===================================================================
RCS src/event-Xt.c
===================================================================
RCS

Index: src/event-Xt.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/event-Xt.c,v
retrieving revision 1.91
diff -u -u -r1.91 event-Xt.c
--- src/event-Xt.c	2005/12/24 19:54:01	1.91
+++ src/event-Xt.c	2007/05/12 10:37:09
@@ -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);
 
Index: src/event-gtk.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/event-gtk.c,v
retrieving revision 1.31
diff -u -u -r1.31 event-gtk.c
--- src/event-gtk.c	2005/07/03 21:48:00	1.31
+++ src/event-gtk.c	2007/05/12 10:37:10
@@ -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);
 

-- 
On the quay of the little Black Sea port, where the rescued pair came once
more into contact with civilization, Dobrinton was bitten by a dog which was
assumed to be mad, though it may only have been indiscriminating. (Saki)



More information about the XEmacs-Patches mailing list