From 4e7b5c95fe6a11ed0718751705d22de55490bcd4 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 26 Dec 2015 09:34:07 +1100 Subject: [PATCH] keymap: make a local copy of any key put in a keymap. When called from C, these are always static. But there is no such guarantee when called from elsewhere. We really should refcount the 'comm' too or something like that. For now, they are never freed. Signed-off-by: NeilBrown --- core-keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-keymap.c b/core-keymap.c index 30ee7abe..4850b737 100644 --- a/core-keymap.c +++ b/core-keymap.c @@ -159,7 +159,7 @@ void key_add(struct map *map, char *k, struct command *comm) (map->size - pos) * sizeof(map->keys[0])); memmove(map->comms+pos+ins_cnt, map->comms+pos, (map->size - pos) * sizeof(struct command *)); - map->keys[pos] = k; + map->keys[pos] = strdup(k); map->comms[pos] = comm; if (comm2) { map->keys[pos+1] = k; -- 2.39.5