From 00039dcdddb3f48d374b30f73fa6f2f7762d4505 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Sun, 24 Apr 2016 00:09:12 +0100 Subject: [PATCH] m_alias: store a copy of alias->name as it will be freed on a rehash --- modules/m_alias.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/m_alias.c b/modules/m_alias.c index 3879a814..307caf4a 100644 --- a/modules/m_alias.c +++ b/modules/m_alias.c @@ -60,9 +60,12 @@ create_aliases(void) RB_DICTIONARY_FOREACH(alias, &iter, alias_dict) { - struct Message *message = rb_malloc(sizeof(struct Message)); + struct Message *message = rb_malloc(sizeof(*message) + strlen(alias->name) + 1); + char *cmd = (void*)message + sizeof(*message); - message->cmd = alias->name; + /* copy the alias name as it will be freed early on a rehash */ + strcpy(cmd, alias->name); + message->cmd = cmd; memcpy(message->handlers, alias_msgtab, sizeof(alias_msgtab)); mod_add_cmd(message);