X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/5366977b4f3c7a50d170bf7a1e29b14c74944db7..f968f34f4b36af5d587dd4169c7476a4a264d450:/src/modules.c diff --git a/src/modules.c b/src/modules.c index 0d0836f..189df07 100644 --- a/src/modules.c +++ b/src/modules.c @@ -28,7 +28,7 @@ #include "modules.h" -#include "s_log.h" +#include "logger.h" #include "ircd.h" #include "client.h" #include "send.h" @@ -37,10 +37,8 @@ #include "numeric.h" #include "parse.h" #include "ircd_defs.h" -#include "irc_string.h" -#include "memory.h" -#include "tools.h" -#include "sprintf_irc.h" +#include "match.h" +#include "s_serv.h" @@ -60,18 +58,19 @@ struct module **modlist = NULL; static const char *core_module_table[] = { + "m_ban", "m_die", "m_error", "m_join", "m_kick", "m_kill", "m_message", + "m_metadata", "m_mode", "m_nick", "m_part", "m_quit", "m_server", - "m_sjoin", "m_squit", NULL }; @@ -80,7 +79,7 @@ static const char *core_module_table[] = { int num_mods = 0; int max_mods = MODS_INCREMENT; -static dlink_list mod_paths; +static rb_dlink_list mod_paths; static int mo_modload(struct Client *, struct Client *, int, const char **); static int mo_modlist(struct Client *, struct Client *, int, const char **); @@ -88,33 +87,43 @@ static int mo_modreload(struct Client *, struct Client *, int, const char **); static int mo_modunload(struct Client *, struct Client *, int, const char **); static int mo_modrestart(struct Client *, struct Client *, int, const char **); +static int me_modload(struct Client *, struct Client *, int, const char **); +static int me_modlist(struct Client *, struct Client *, int, const char **); +static int me_modreload(struct Client *, struct Client *, int, const char **); +static int me_modunload(struct Client *, struct Client *, int, const char **); +static int me_modrestart(struct Client *, struct Client *, int, const char **); + +static int do_modload(struct Client *, const char *); +static int do_modunload(struct Client *, const char *); +static int do_modreload(struct Client *, const char *); +static int do_modlist(struct Client *, const char *); +static int do_modrestart(struct Client *); + struct Message modload_msgtab = { "MODLOAD", 0, 0, 0, MFLG_SLOW, - {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_modload, 2}} + {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_modload, 2}, {mo_modload, 2}} }; struct Message modunload_msgtab = { "MODUNLOAD", 0, 0, 0, MFLG_SLOW, - {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_modunload, 2}} + {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_modunload, 2}, {mo_modunload, 2}} }; struct Message modreload_msgtab = { "MODRELOAD", 0, 0, 0, MFLG_SLOW, - {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_modreload, 2}} + {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_modreload, 2}, {mo_modreload, 2}} }; struct Message modlist_msgtab = { "MODLIST", 0, 0, 0, MFLG_SLOW, - {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_modlist, 0}} + {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_modlist, 0}, {mo_modlist, 0}} }; struct Message modrestart_msgtab = { "MODRESTART", 0, 0, 0, MFLG_SLOW, - {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_modrestart, 0}} + {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_modrestart, 0}, {mo_modrestart, 0}} }; -extern struct Message error_msgtab; - void modules_init(void) { @@ -138,10 +147,10 @@ modules_init(void) static struct module_path * mod_find_path(const char *path) { - dlink_node *ptr; + rb_dlink_node *ptr; struct module_path *mpath; - DLINK_FOREACH(ptr, mod_paths.head) + RB_DLINK_FOREACH(ptr, mod_paths.head) { mpath = ptr->data; @@ -166,10 +175,10 @@ mod_add_path(const char *path) if(mod_find_path(path)) return; - pathst = MyMalloc(sizeof(struct module_path)); + pathst = rb_malloc(sizeof(struct module_path)); strcpy(pathst->path, path); - dlinkAddAlloc(pathst, &mod_paths); + rb_dlinkAddAlloc(pathst, &mod_paths); } /* mod_clear_paths() @@ -181,39 +190,18 @@ mod_add_path(const char *path) void mod_clear_paths(void) { - dlink_node *ptr, *next_ptr; + rb_dlink_node *ptr, *next_ptr; - DLINK_FOREACH_SAFE(ptr, next_ptr, mod_paths.head) + RB_DLINK_FOREACH_SAFE(ptr, next_ptr, mod_paths.head) { - MyFree(ptr->data); - free_dlink_node(ptr); + rb_free(ptr->data); + rb_free_rb_dlink_node(ptr); } mod_paths.head = mod_paths.tail = NULL; mod_paths.length = 0; } -/* irc_basename - * - * input - - * output - - * side effects - - */ -char * -irc_basename(const char *path) -{ - char *mod_basename = MyMalloc(strlen(path) + 1); - const char *s; - - if(!(s = strrchr(path, '/'))) - s = path; - else - s++; - - (void) strcpy(mod_basename, s); - return mod_basename; -} - /* findmodule_byname * * input - @@ -250,7 +238,7 @@ load_all_modules(int warn) modules_init(); - modlist = (struct module **) MyMalloc(sizeof(struct module) * (MODS_INCREMENT)); + modlist = (struct module **) rb_malloc(sizeof(struct module) * (MODS_INCREMENT)); max_mods = MODS_INCREMENT; @@ -267,7 +255,7 @@ load_all_modules(int warn) len = strlen(ldirent->d_name); if((len > 3) && !strcmp(ldirent->d_name+len-3, SHARED_SUFFIX)) { - (void) ircsnprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name); + (void) rb_snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s", AUTOMODPATH, ldirent->d_name); (void) load_a_module(module_fq_name, warn, 0); } @@ -290,7 +278,7 @@ load_core_modules(int warn) for (i = 0; core_module_table[i]; i++) { - ircsnprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH, + rb_snprintf(module_name, sizeof(module_name), "%s/%s%s", MODPATH, core_module_table[i], SHARED_SUFFIX); if(load_a_module(module_name, warn, 1) == -1) @@ -313,7 +301,7 @@ int load_one_module(const char *path, int coremodule) { char modpath[MAXPATHLEN]; - dlink_node *pathst; + rb_dlink_node *pathst; struct module_path *mpath; struct stat statbuf; @@ -321,11 +309,11 @@ load_one_module(const char *path, int coremodule) if (server_state_foreground == 1) inotice("loading module %s ...", path); - DLINK_FOREACH(pathst, mod_paths.head) + RB_DLINK_FOREACH(pathst, mod_paths.head) { mpath = pathst->data; - ircsnprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path); + rb_snprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path); if((strstr(modpath, "../") == NULL) && (strstr(modpath, "/..") == NULL)) { if(stat(modpath, &statbuf) == 0) @@ -343,7 +331,7 @@ load_one_module(const char *path, int coremodule) } } - sendto_realops_snomask(SNO_GENERAL, L_ALL, "Cannot locate module %s", path); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Cannot locate module %s", path); return -1; } @@ -352,8 +340,6 @@ load_one_module(const char *path, int coremodule) static int mo_modload(struct Client *client_p, struct Client *source_p, int parc, const char **parv) { - char *m_bn; - if(!IsOperAdmin(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), @@ -361,18 +347,45 @@ mo_modload(struct Client *client_p, struct Client *source_p, int parc, const cha return 0; } - m_bn = irc_basename(parv[1]); + if(parc > 2) + { + sendto_match_servs(source_p, parv[2], CAP_ENCAP, NOCAPS, + "ENCAP %s MODLOAD %s", parv[2], parv[1]); + if (match(parv[2], me.name) == 0) + return 0; + } + + return do_modload(source_p, parv[1]); +} + +static int +me_modload(struct Client *client_p, struct Client *source_p, int parc, const char **parv) +{ + if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE)) + { + sendto_one_notice(source_p, ":*** You do not have an appropriate shared block " + "to load modules on this server."); + return 0; + } + + return do_modload(source_p, parv[1]); +} + +static int +do_modload(struct Client *source_p, const char *module) +{ + char *m_bn = rb_basename(module); if(findmodule_byname(m_bn) != -1) { sendto_one_notice(source_p, ":Module %s is already loaded", m_bn); - MyFree(m_bn); + rb_free(m_bn); return 0; } - load_one_module(parv[1], 0); + load_one_module(module, 0); - MyFree(m_bn); + rb_free(m_bn); return 0; } @@ -382,9 +395,6 @@ mo_modload(struct Client *client_p, struct Client *source_p, int parc, const cha static int mo_modunload(struct Client *client_p, struct Client *source_p, int parc, const char **parv) { - char *m_bn; - int modindex; - if(!IsOperAdmin(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), @@ -392,19 +402,47 @@ mo_modunload(struct Client *client_p, struct Client *source_p, int parc, const c return 0; } - m_bn = irc_basename(parv[1]); + if(parc > 2) + { + sendto_match_servs(source_p, parv[2], CAP_ENCAP, NOCAPS, + "ENCAP %s MODUNLOAD %s", parv[2], parv[1]); + if (match(parv[2], me.name) == 0) + return 0; + } + + return do_modunload(source_p, parv[1]); +} + +static int +me_modunload(struct Client *client_p, struct Client *source_p, int parc, const char **parv) +{ + if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE)) + { + sendto_one_notice(source_p, ":*** You do not have an appropriate shared block " + "to load modules on this server."); + return 0; + } + + return do_modunload(source_p, parv[1]); +} + +static int +do_modunload(struct Client *source_p, const char *module) +{ + int modindex; + char *m_bn = rb_basename(module); if((modindex = findmodule_byname(m_bn)) == -1) { sendto_one_notice(source_p, ":Module %s is not loaded", m_bn); - MyFree(m_bn); + rb_free(m_bn); return 0; } if(modlist[modindex]->core == 1) { sendto_one_notice(source_p, ":Module %s is a core module and may not be unloaded", m_bn); - MyFree(m_bn); + rb_free(m_bn); return 0; } @@ -413,7 +451,7 @@ mo_modunload(struct Client *client_p, struct Client *source_p, int parc, const c sendto_one_notice(source_p, ":Module %s is not loaded", m_bn); } - MyFree(m_bn); + rb_free(m_bn); return 0; } @@ -421,10 +459,6 @@ mo_modunload(struct Client *client_p, struct Client *source_p, int parc, const c static int mo_modreload(struct Client *client_p, struct Client *source_p, int parc, const char **parv) { - char *m_bn; - int modindex; - int check_core; - if(!IsOperAdmin(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), @@ -432,12 +466,41 @@ mo_modreload(struct Client *client_p, struct Client *source_p, int parc, const c return 0; } - m_bn = irc_basename(parv[1]); + if(parc > 2) + { + sendto_match_servs(source_p, parv[2], CAP_ENCAP, NOCAPS, + "ENCAP %s MODRELOAD %s", parv[2], parv[1]); + if (match(parv[2], me.name) == 0) + return 0; + } + + return do_modreload(source_p, parv[1]); +} + +static int +me_modreload(struct Client *client_p, struct Client *source_p, int parc, const char **parv) +{ + if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE)) + { + sendto_one_notice(source_p, ":*** You do not have an appropriate shared block " + "to load modules on this server."); + return 0; + } + + return do_modreload(source_p, parv[1]); +} + +static int +do_modreload(struct Client *source_p, const char *module) +{ + int modindex; + int check_core; + char *m_bn = rb_basename(module); if((modindex = findmodule_byname(m_bn)) == -1) { sendto_one_notice(source_p, ":Module %s is not loaded", m_bn); - MyFree(m_bn); + rb_free(m_bn); return 0; } @@ -446,19 +509,19 @@ mo_modreload(struct Client *client_p, struct Client *source_p, int parc, const c if(unload_one_module(m_bn, 1) == -1) { sendto_one_notice(source_p, ":Module %s is not loaded", m_bn); - MyFree(m_bn); + rb_free(m_bn); return 0; } - if((load_one_module(parv[1], check_core) == -1) && check_core) + if((load_one_module(m_bn, check_core) == -1) && check_core) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, - "Error reloading core module: %s: terminating ircd", parv[1]); - ilog(L_MAIN, "Error loading core module %s: terminating ircd", parv[1]); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, + "Error reloading core module: %s: terminating ircd", m_bn); + ilog(L_MAIN, "Error loading core module %s: terminating ircd", m_bn); exit(0); } - MyFree(m_bn); + rb_free(m_bn); return 0; } @@ -466,8 +529,6 @@ mo_modreload(struct Client *client_p, struct Client *source_p, int parc, const c static int mo_modlist(struct Client *client_p, struct Client *source_p, int parc, const char **parv) { - int i; - if(!IsOperAdmin(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), @@ -475,11 +536,40 @@ mo_modlist(struct Client *client_p, struct Client *source_p, int parc, const cha return 0; } + if(parc > 2) + { + sendto_match_servs(source_p, parv[2], CAP_ENCAP, NOCAPS, + "ENCAP %s MODLIST %s", parv[2], parv[1]); + if (match(parv[2], me.name) == 0) + return 0; + } + + return do_modlist(source_p, parc > 1 ? parv[1] : 0); +} + +static int +me_modlist(struct Client *client_p, struct Client *source_p, int parc, const char **parv) +{ + if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE)) + { + sendto_one_notice(source_p, ":*** You do not have an appropriate shared block " + "to load modules on this server."); + return 0; + } + + return do_modlist(source_p, parv[1]); +} + +static int +do_modlist(struct Client *source_p, const char *pattern) +{ + int i; + for (i = 0; i < num_mods; i++) { - if(parc > 1) + if(pattern) { - if(match(parv[1], modlist[i]->name)) + if(match(pattern, modlist[i]->name)) { sendto_one(source_p, form_str(RPL_MODLIST), me.name, source_p->name, @@ -505,8 +595,6 @@ mo_modlist(struct Client *client_p, struct Client *source_p, int parc, const cha static int mo_modrestart(struct Client *client_p, struct Client *source_p, int parc, const char **parv) { - int modnum; - if(!IsOperAdmin(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), @@ -514,6 +602,35 @@ mo_modrestart(struct Client *client_p, struct Client *source_p, int parc, const return 0; } + if(parc > 1) + { + sendto_match_servs(source_p, parv[1], CAP_ENCAP, NOCAPS, + "ENCAP %s MODRESTART", parv[1]); + if (match(parv[1], me.name) == 0) + return 0; + } + + return do_modrestart(source_p); +} + +static int +me_modrestart(struct Client *client_p, struct Client *source_p, int parc, const char **parv) +{ + if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_MODULE)) + { + sendto_one_notice(source_p, ":*** You do not have an appropriate shared block " + "to load modules on this server."); + return 0; + } + + return do_modrestart(source_p); +} + +static int +do_modrestart(struct Client *source_p) +{ + int modnum; + sendto_one_notice(source_p, ":Reloading all modules"); modnum = num_mods; @@ -524,7 +641,7 @@ mo_modrestart(struct Client *client_p, struct Client *source_p, int parc, const load_core_modules(0); rehash(0); - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Module Restart: %d modules unloaded, %d modules loaded", modnum, num_mods); ilog(L_MAIN, "Module Restart: %d modules unloaded, %d modules loaded", modnum, num_mods); @@ -537,6 +654,10 @@ mo_modrestart(struct Client *client_p, struct Client *source_p, int parc, const #define RTLD_NOW RTLD_LAZY /* openbsd deficiency */ #endif +#ifndef RTLD_LOCAL +#define RTLD_LOCAL 0 +#endif + #ifdef CHARYBDIS_PROFILE # ifndef RTLD_PROFILE # warning libdl may not support profiling, sucks. :( @@ -589,7 +710,7 @@ static char *myErrorTable[] = { "Loading file as object failed\n", void undefinedErrorHandler(const char *symbolName) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, "Undefined symbol: %s", symbolName); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Undefined symbol: %s", symbolName); ilog(L_MAIN, "Undefined symbol: %s", symbolName); return; } @@ -601,7 +722,7 @@ multipleErrorHandler(NSSymbol s, NSModule old, NSModule new) ** This results in substantial leaking of memory... Should free one ** module, maybe? */ - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Symbol `%s' found in `%s' and `%s'", NSNameOfSymbol(s), NSNameOfModule(old), NSNameOfModule(new)); ilog(L_MAIN, "Symbol `%s' found in `%s' and `%s'", @@ -614,7 +735,7 @@ void linkEditErrorHandler(NSLinkEditErrors errorClass, int errnum, const char *fileName, const char *errorString) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Link editor error: %s for %s", errorString, fileName); ilog(L_MAIN, "Link editor error: %s for %s", errorString, fileName); return; @@ -749,7 +870,7 @@ unload_one_module(const char *name, int warn) break; } default: - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Unknown/unsupported MAPI version %d when unloading %s!", modlist[modindex]->mapi_version, modlist[modindex]->name); ilog(L_MAIN, "Unknown/unsupported MAPI version %d when unloading %s!", @@ -759,8 +880,8 @@ unload_one_module(const char *name, int warn) dlclose(modlist[modindex]->address); - MyFree(modlist[modindex]->name); - memcpy(&modlist[modindex], &modlist[modindex + 1], + rb_free(modlist[modindex]->name); + memmove(&modlist[modindex], &modlist[modindex + 1], sizeof(struct module) * ((num_mods - 1) - modindex)); if(num_mods != 0) @@ -769,7 +890,7 @@ unload_one_module(const char *name, int warn) if(warn == 1) { ilog(L_MAIN, "Module %s unloaded", name); - sendto_realops_snomask(SNO_GENERAL, L_ALL, "Module %s unloaded", name); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Module %s unloaded", name); } return 0; @@ -793,22 +914,22 @@ load_a_module(const char *path, int warn, int core) int *mapi_version; - mod_basename = irc_basename(path); + mod_basename = rb_basename(path); #ifdef CHARYBDIS_PROFILE - tmpptr = dlopen(path, RTLD_NOW | RTLD_PROFILE); + tmpptr = dlopen(path, RTLD_NOW | RTLD_LOCAL | RTLD_PROFILE); #else - tmpptr = dlopen(path, RTLD_NOW); + tmpptr = dlopen(path, RTLD_NOW | RTLD_LOCAL); #endif if(tmpptr == NULL) { const char *err = dlerror(); - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Error loading module %s: %s", mod_basename, err); ilog(L_MAIN, "Error loading module %s: %s", mod_basename, err); - MyFree(mod_basename); + rb_free(mod_basename); return -1; } @@ -824,12 +945,12 @@ load_a_module(const char *path, int warn, int core) && (mapi_version = (int *) (uintptr_t) dlsym(tmpptr, "__mheader")) == NULL) || MAPI_MAGIC(*mapi_version) != MAPI_MAGIC_HDR) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Data format error: module %s has no MAPI header.", mod_basename); ilog(L_MAIN, "Data format error: module %s has no MAPI header.", mod_basename); (void) dlclose(tmpptr); - MyFree(mod_basename); + rb_free(mod_basename); return -1; } @@ -842,11 +963,11 @@ load_a_module(const char *path, int warn, int core) { ilog(L_MAIN, "Module %s indicated failure during load.", mod_basename); - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Module %s indicated failure during load.", mod_basename); dlclose(tmpptr); - MyFree(mod_basename); + rb_free(mod_basename); return -1; } if(mheader->mapi_command_list) @@ -877,11 +998,11 @@ load_a_module(const char *path, int warn, int core) default: ilog(L_MAIN, "Module %s has unknown/unsupported MAPI version %d.", mod_basename, MAPI_VERSION(*mapi_version)); - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Module %s has unknown/unsupported MAPI version %d.", mod_basename, *mapi_version); dlclose(tmpptr); - MyFree(mod_basename); + rb_free(mod_basename); return -1; } @@ -890,25 +1011,25 @@ load_a_module(const char *path, int warn, int core) increase_modlist(); - modlist[num_mods] = MyMalloc(sizeof(struct module)); + modlist[num_mods] = rb_malloc(sizeof(struct module)); modlist[num_mods]->address = tmpptr; modlist[num_mods]->version = ver; modlist[num_mods]->core = core; - DupString(modlist[num_mods]->name, mod_basename); + modlist[num_mods]->name = rb_strdup(mod_basename); modlist[num_mods]->mapi_header = mapi_version; modlist[num_mods]->mapi_version = MAPI_VERSION(*mapi_version); num_mods++; if(warn == 1) { - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Module %s [version: %s; MAPI version: %d] loaded at 0x%lx", mod_basename, ver, MAPI_VERSION(*mapi_version), (unsigned long) tmpptr); ilog(L_MAIN, "Module %s [version: %s; MAPI version: %d] loaded at 0x%lx", mod_basename, ver, MAPI_VERSION(*mapi_version), (unsigned long) tmpptr); } - MyFree(mod_basename); + rb_free(mod_basename); return 0; } @@ -927,11 +1048,11 @@ increase_modlist(void) if((num_mods + 1) < max_mods) return; - new_modlist = (struct module **) MyMalloc(sizeof(struct module) * + new_modlist = (struct module **) rb_malloc(sizeof(struct module) * (max_mods + MODS_INCREMENT)); memcpy((void *) new_modlist, (void *) modlist, sizeof(struct module) * num_mods); - MyFree(modlist); + rb_free(modlist); modlist = new_modlist; max_mods += MODS_INCREMENT; }