From: NeilBrown Date: Fri, 25 Dec 2015 22:34:07 +0000 (+1100) Subject: keymap: make a local copy of any key put in a keymap. X-Git-Tag: lca2016~39 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=4e7b5c95fe6a11ed0718751705d22de55490bcd4;p=edlib.git 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 --- 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;