0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-29 00:44:17 +01:00

m_alias: store a copy of alias->name as it will be freed on a rehash

This commit is contained in:
Simon Arlott 2016-04-24 00:09:12 +01:00
parent 5c317f1313
commit 00039dcddd
No known key found for this signature in database
GPG key ID: C8975F2043CA5D24

View file

@ -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);