From ce1dde140ce2fd89cad33c4e4c994a5bede74ebe Mon Sep 17 00:00:00 2001 From: Alex Roper Date: Thu, 25 Oct 2012 15:49:51 -0400 Subject: [PATCH] Fixed crash when there is no keycode associated with the to of a mapping's keysym. --- xcape.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xcape.c b/xcape.c index e5894d7..1ed4eef 100644 --- a/xcape.c +++ b/xcape.c @@ -375,6 +375,7 @@ KeyMap_t *parse_token (Display *dpy, char *token) KeyMap_t *km = NULL; KeySym ks; char *from, *to, *key; + KeyCode code; to = token; from = strsep (&to, "="); @@ -403,8 +404,15 @@ KeyMap_t *parse_token (Display *dpy, char *token) return NULL; } - km->to_keys = key_add_key (km->to_keys, - XKeysymToKeycode (dpy, ks)); + code = XKeysymToKeycode (dpy, ks); + if (code == 0) + { + fprintf (stderr, "WARNING: No keycode found for keysym " + "%s (0x%x) in mapping %s. Ignoring this " + "mapping.\n", key, (unsigned int)ks, token); + return NULL; + } + km->to_keys = key_add_key (km->to_keys, code); } } else