summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-25 04:12:54 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-25 04:12:54 +0000
commit6e3aa36876fe85caac9919420ece61d981f046a4 (patch)
tree1af4ea7e8625fb15ec7026d6b777c30652087e45
parent7a429517af09a2240f938a5570f83e4c6b9f9f9f (diff)
Fixed passing invalid channel pointer to OnPartChannel if the last user in a channel parted, now we use NULL and just give it the channel name
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2586 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--include/modules.h6
-rw-r--r--src/channels.c5
2 files changed, 7 insertions, 4 deletions
diff --git a/include/modules.h b/include/modules.h
index 7a122804d..f7354f4e2 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -640,9 +640,11 @@ class CoreExport Module
/** Called when a user parts a channel
* @param u The user
- * @param c The channel
+ * @param c The channel, may be NULL if the channel no longer exists
+ * @param channel The channel name
+ * @param msg The part reason
*/
- virtual void OnPartChannel(User *u, Channel *c, const std::string &msg) { }
+ virtual void OnPartChannel(User *u, Channel *c, const std::string &channel, const std::string &msg) { }
/** Called before a user joins a channel
* @param u The user
diff --git a/src/channels.c b/src/channels.c
index 6bd4e5350..1013d7e9d 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -873,7 +873,7 @@ void do_join(const char *source, int ac, const char **av)
channame = sstrdup(c->chan->name);
FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c->chan));
chan_deluser(user, c->chan);
- FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, c->chan, ""));
+ FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(channame), channame, ""));
delete [] channame;
delete c;
c = nextc;
@@ -1017,10 +1017,11 @@ void do_part(const char *source, int ac, const char **av)
return;
}
FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c->chan));
+ std::string ChannelName = c->chan->name;
chan_deluser(user, c->chan);
- FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, c->chan, av[1] ? av[1] : ""));
+ FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName.c_str()), ChannelName, av[1] ? av[1] : ""));
if (c->next)
c->next->prev = c->prev;