From 3eb8a4e3251386c676c3d0696dc20837e9f58010 Mon Sep 17 00:00:00 2001 From: sabetts Date: Wed, 12 Dec 2001 04:47:25 +0000 Subject: (parse_keydesc): Don't mangle the key description argument. --- src/actions.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/actions.c') 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 -- cgit v1.2.3