diff options
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/actions.c b/src/actions.c index 367968d..950c22d 100644 --- a/src/actions.c +++ b/src/actions.c @@ -328,16 +328,20 @@ static int string_to_keysym (char *str) return keysym; } +/* Parse a key description. 's' is, naturally, the key description. */ struct rp_key* -parse_keydesc (char *keydesc) +parse_keydesc (char *s) { static struct rp_key key; struct rp_key *p = &key; - char *token, *next_token; + char *token, *next_token, *keydesc; - if (!keydesc) + if (s == NULL) return NULL; + /* Avoid mangling s. */ + keydesc = xstrdup (s); + p->state = 0; p->sym = 0; @@ -354,6 +358,7 @@ parse_keydesc (char *keydesc) if (token == NULL) { /* It was nothing but hyphens */ + free (keydesc); return NULL; } @@ -394,6 +399,7 @@ parse_keydesc (char *keydesc) } else { + free (keydesc); return NULL; } } @@ -402,6 +408,8 @@ parse_keydesc (char *keydesc) } while (next_token != NULL); } + free (keydesc); + if (!p->sym) return NULL; else |