Skip to content
Snippets Groups Projects
Commit 1bee951a authored by Olivier Fourdan's avatar Olivier Fourdan
Browse files

Fix memory leak in key parsing as spotted by Thomas Leonard <tal00r@ecs.soton.ac.uk>

(Old svn revision: 10655)
parent 3915d8cb
No related branches found
No related tags found
No related merge requests found
......@@ -30,8 +30,6 @@
#include "keyboard.h"
#include "debug.h"
#define PARSEKEY(s, k) strstr(g_ascii_strdown (s, strlen (s)), g_ascii_strdown(k, strlen (k)))
unsigned int KeyMask;
unsigned int ButtonMask;
unsigned int ButtonKeyMask;
......@@ -59,15 +57,29 @@ void parseKeyString(Display * dpy, MyKey * key, char *str)
k = strrchr(str, '+');
if(k)
{
gchar *tmp;
tmp = g_ascii_strdown(str, -1);
key->keycode = XKeysymToKeycode(dpy, XStringToKeysym(k + 1));
if(PARSEKEY(str, "Shift"))
if(strstr(str, "shift"))
{
key->modifier = key->modifier | ShiftMask;
if(PARSEKEY(str, "Control"))
}
if(strstr(str, "control"))
{
key->modifier = key->modifier | ControlMask;
if(PARSEKEY(str, "Alt") || PARSEKEY(str, "Mod1"))
}
if(strstr(str, "alt") || strstr(str, "mod1"))
{
key->modifier = key->modifier | AltMask;
if(PARSEKEY(str, "Meta") || PARSEKEY(str, "Mod2"))
}
if(strstr(str, "meta") || strstr(str, "mod2"))
{
key->modifier = key->modifier | MetaMask;
}
g_free(tmp);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment