diff options
author | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-06-08 16:28:50 +0000 |
---|---|---|
committer | Adam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864> | 2010-06-08 16:28:50 +0000 |
commit | c01f8cad22a72bf1a70bf77afe841a6ba60c73fe (patch) | |
tree | 0b7754c466e7933f8ffbd5661498c0eb343ad36a /src | |
parent | cea53460b02f51c1d91540f4d371262bf8bdfa63 (diff) |
Never unset mod_current_module in functions that modules might call, instead save the old values and reset them
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/stable@3000 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/commands.c | 8 | ||||
-rw-r--r-- | src/events.c | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/commands.c b/src/commands.c index cbc99b800..481a74854 100644 --- a/src/commands.c +++ b/src/commands.c @@ -95,6 +95,8 @@ void do_run_cmd(char *service, User * u, Command * c, const char *cmd) notice_lang(service, u, OPER_DEFCON_DENIED); } } else { + char *mod_current_module_name_save = mod_current_module_name; + Module *mod_current_module_save = mod_current_module; mod_current_module_name = c->mod_name; mod_current_module = findModule(c->mod_name); if ((c->has_priv == NULL) || c->has_priv(u)) { @@ -106,8 +108,6 @@ void do_run_cmd(char *service, User * u, Command * c, const char *cmd) mod_current_module = findModule(current->mod_name); if (current->routine) retVal = current->routine(u); - mod_current_module_name = NULL; - mod_current_module = NULL; current = current->next; } } @@ -116,8 +116,8 @@ void do_run_cmd(char *service, User * u, Command * c, const char *cmd) alog("Access denied for %s with service %s and command %s", u->nick, service, cmd); } - mod_current_module_name = NULL; - mod_current_module = NULL; + mod_current_module_name = mod_current_module_name_save; + mod_current_module = mod_current_module_save; } } else { if ((!checkDefCon(DEFCON_SILENT_OPER_ONLY)) || is_oper(u)) { diff --git a/src/events.c b/src/events.c index 2d7006a0c..58871d2d4 100644 --- a/src/events.c +++ b/src/events.c @@ -127,23 +127,23 @@ void event_message_process(char *eventbuf) /* Do something with the message. */ evm = find_event(cmd); if (evm) { + char *mod_current_module_name_save = mod_current_module_name; + Module *mod_current_module_save = mod_current_module; if (evm->func) { mod_current_module_name = evm->mod_name; mod_current_module = findModule(evm->mod_name); retVal = evm->func(source, ac, av); - mod_current_module_name = NULL; - mod_current_module = NULL; if (retVal == MOD_CONT) { current = evm->next; while (current && current->func && retVal == MOD_CONT) { mod_current_module_name = current->mod_name; mod_current_module = findModule(current->mod_name); retVal = current->func(source, ac, av); - mod_current_module_name = NULL; - mod_current_module = NULL; current = current->next; } } + mod_current_module_name = mod_current_module_name_save; + mod_current_module = mod_current_module_save; } } /* Free argument list we created */ @@ -162,22 +162,22 @@ void event_process_hook(const char *name, int argc, char **argv) evh = find_eventhook(name); if (evh) { if (evh->func) { + char *mod_current_module_name_save = mod_current_module_name; + Module *mod_current_module_save = mod_current_module; mod_current_module = findModule(evh->mod_name); mod_current_module_name = evh->mod_name; retVal = evh->func(argc, argv); - mod_current_module = NULL; - mod_current_module_name = NULL; if (retVal == MOD_CONT) { current = evh->next; while (current && current->func && retVal == MOD_CONT) { mod_current_module = findModule(current->mod_name); mod_current_module_name = current->mod_name; retVal = current->func(argc, argv); - mod_current_module = NULL; - mod_current_module_name = NULL; current = current->next; } } + mod_current_module_name = mod_current_module_name_save; + mod_current_module = mod_current_module_save; } } } |