[PATCH v2 1/3] [libx11] Variable "map" goes out of scope

Erkki Seppälä erkki.seppala at vincit.fi
Mon Jan 31 02:03:32 PST 2011


Release modifiermap before returning. Reordered code to call
XGetModifierMapping after the first return from the function.

Signed-off-by: Erkki Seppälä <erkki.seppala at vincit.fi>

diff --git a/modules/im/ximcp/imThaiFlt.c b/modules/im/ximcp/imThaiFlt.c
index e0b3988..e2b0458 100644
--- a/modules/im/ximcp/imThaiFlt.c
+++ b/modules/im/ximcp/imThaiFlt.c
@@ -1262,15 +1262,20 @@ Private unsigned
 NumLockMask(Display *d)
 {
     int i;
-    XModifierKeymap *map = XGetModifierMapping (d);
+    XModifierKeymap *map;
     KeyCode numlock_keycode = XKeysymToKeycode (d, XK_Num_Lock);
     if (numlock_keycode == NoSymbol)
         return 0;
 
+    map = XGetModifierMapping (d);
+
     for (i = 0; i < 8; i++) {
-        if (map->modifiermap[map->max_keypermod * i] == numlock_keycode)
+        if (map->modifiermap[map->max_keypermod * i] == numlock_keycode) {
+            XFreeModifiermap(map);
             return 1 << i;
+        }
     }
+    XFreeModifiermap(map);
     return 0;
 }
 
-- 
1.7.0.4



More information about the xorg-devel mailing list