From e4815126b5f0befca091fe7c9ce40477ef1d5f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkki=20Sepp=C3=A4l=C3=A4?= Date: Mon, 10 Jan 2011 16:22:45 +0200 Subject: im/ximcp: release modifiermap before returning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Variable "map" goes out of scope Release modifiermap before returning. Reordered code to call XGetModifierMapping after the first return from the function. Signed-off-by: Erkki Seppälä Reviewed-by: Dirk Wallenstein Backported-to-NX-by: Ulrich Sibiller --- nx-X11/lib/X11/imThaiFlt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'nx-X11/lib/X11/imThaiFlt.c') diff --git a/nx-X11/lib/X11/imThaiFlt.c b/nx-X11/lib/X11/imThaiFlt.c index 5f67373d1..72f6f2e7a 100644 --- a/nx-X11/lib/X11/imThaiFlt.c +++ b/nx-X11/lib/X11/imThaiFlt.c @@ -1262,15 +1262,22 @@ 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); + if (!map) + return 0; + 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; } -- cgit v1.2.3