src/hash.c (NickChange): Stop iterating if the user is killed by any hook.
(AddChannelUser): Likewise.
src/nickserv.c (set_user_handle_info): Likewise.
src/proto-common.c (of_list, of_size, of_used, reg_oper_func,
call_oper_funcs): Move from the proto-*.c files. Make call_oper_funcs
stop iterating if the user is killed by any hook.
src/proto-bahahmut.c (AddUser): Likewise.
(of_list, of_size, of_used, reg_oper_func, call_oper_funcs): Move to
proto-common.c
src/proto-p10.c: Likewise to proto-bahamut.c.
#endif
/* Make callbacks for nick changes. Do this with new nick in
- * place because that is slightly more useful.
+ * place because that is slightly more useful. Stop if the user
+ * gets killed by any of the hooks, so that later hooks do not get
+ * confused by the user having disappeared.
*/
- for (nn=0; nn<ncf2_used; nn++)
+ for (nn=0; (nn<ncf2_used) && !user->dead; nn++)
ncf2_list[nn](user, old_nick);
user->timestamp = now;
if (IsLocal(user) && !no_announce)
irc_join(user, channel);
}
- for (n=0; n<jf_used; n++) {
+ for (n=0; (n<jf_used) && !user->dead; n++) {
/* Callbacks return true if they kick or kill the user,
* and we can continue without removing mNode. */
if (jf_list[n](mNode))
user->handle_info = hi;
if (hi && !hi->users && !hi->opserv_level)
HANDLE_CLEAR_FLAG(hi, HELPING);
- for (n=0; n<auth_func_used; n++)
+ for (n=0; (n<auth_func_used) && !user->dead; n++)
auth_func_list[n](user, old_info);
if (hi) {
struct nick_info *ni;
if (dummy) uNode->modes |= FLAGS_DUMMY;
if (stamp) call_account_func(uNode, NULL, 0, stamp);
if (IsLocal(uNode)) irc_user(uNode);
- for (nn=0; nn<nuf_used; nn++) {
+ for (nn=0; (nn<nuf_used) && !uNode->dead; nn++) {
if (nuf_list[nn](uNode)) break;
}
return uNode;
return 1;
}
-static oper_func_t *of_list;
-static unsigned int of_size = 0, of_used = 0;
-
void parse_cleanup(void) {
unsigned int nn;
- if (of_list) free(of_list);
+ free(of_list);
dict_delete(irc_func_dict);
dict_delete(service_msginfo_dict);
free(mcf_list);
}
}
-void
-reg_oper_func(oper_func_t handler)
-{
- if (of_used == of_size) {
- if (of_size) {
- of_size <<= 1;
- of_list = realloc(of_list, of_size*sizeof(oper_func_t));
- } else {
- of_size = 8;
- of_list = malloc(of_size*sizeof(oper_func_t));
- }
- }
- of_list[of_used++] = handler;
-}
-
-static void
-call_oper_funcs(struct userNode *user)
-{
- unsigned int n;
- if (IsLocal(user)) return;
- for (n=0; n<of_used; n++)
- {
- of_list[n](user);
- }
-}
-
void mod_usermode(struct userNode *user, const char *mode_change) {
int add = 1;
mcf_list[mcf_used++] = handler;
}
+static oper_func_t *of_list;
+static unsigned int of_size = 0, of_used = 0;
+
+void
+reg_oper_func(oper_func_t handler)
+{
+ if (of_used == of_size) {
+ if (of_size) {
+ of_size <<= 1;
+ of_list = realloc(of_list, of_size*sizeof(oper_func_t));
+ } else {
+ of_size = 8;
+ of_list = malloc(of_size*sizeof(oper_func_t));
+ }
+ }
+ of_list[of_used++] = handler;
+}
+
+static void
+call_oper_funcs(struct userNode *user)
+{
+ unsigned int n;
+ if (IsLocal(user))
+ return;
+ for (n=0; (n<of_used) && !user->dead; n++)
+ {
+ of_list[n](user);
+ }
+}
+
struct mod_chanmode *
mod_chanmode_alloc(unsigned int argc)
{
return 1;
}
-static oper_func_t *of_list;
-static unsigned int of_size = 0, of_used = 0;
-
void
free_user(struct userNode *user)
{
}
if (IsLocal(uNode))
irc_user(uNode);
- for (n=0; n<nuf_used; n++)
+ for (n=0; (n<nuf_used) && !uNode->dead; n++)
if (nuf_list[n](uNode))
break;
return uNode;
notice_funcs[user->num_local] = NULL;
}
-void
-reg_oper_func(oper_func_t handler)
-{
- if (of_used == of_size) {
- if (of_size) {
- of_size <<= 1;
- of_list = realloc(of_list, of_size*sizeof(oper_func_t));
- } else {
- of_size = 8;
- of_list = malloc(of_size*sizeof(oper_func_t));
- }
- }
- of_list[of_used++] = handler;
-}
-
-static void
-call_oper_funcs(struct userNode *user)
-{
- unsigned int n;
- if (IsLocal(user))
- return;
- for (n=0; n<of_used; n++)
- of_list[n](user);
-}
-
static void
send_burst(void)
{