From ba2052f92e76dfe28743aa19a4cc7dc4e098a99b Mon Sep 17 00:00:00 2001 From: Michael Ortmann <41313082+michaelortmann@users.noreply.github.com> Date: Sun, 1 Dec 2024 16:52:48 +0100 Subject: [PATCH] Fix crash looking up departed channel member Found by: BigBadWouf Patch by: michaelortmann Fixes: #1708 --- src/mod/irc.mod/chan.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mod/irc.mod/chan.c b/src/mod/irc.mod/chan.c index 2467b2d1b..7e57ffcfa 100644 --- a/src/mod/irc.mod/chan.c +++ b/src/mod/irc.mod/chan.c @@ -2240,7 +2240,7 @@ static int gotjoin(char *from, char *channame) */ static int gotpart(char *from, char *msg) { - char *nick, *chname, *key; + char *nick, *chname, uhost[UHOSTLEN], *key; struct chanset_t *chan; struct userrec *u; memberlist *m; @@ -2255,9 +2255,14 @@ static int gotpart(char *from, char *msg) return 0; } if (chan && !channel_pending(chan)) { + strlcpy(uhost, from, sizeof uhost); nick = splitnick(&from); m = ismember(chan, nick); - u = get_user_from_member(m); + // TODO: check account from rawt account-tags + if (m) + u = get_user_from_member(m); + else + u = get_user_by_host(uhost); if (!channel_active(chan)) { /* whoa! */ putlog(LOG_MISC, chan->dname, @@ -2276,7 +2281,8 @@ static int gotpart(char *from, char *msg) if (!chan) return 0; - killmember(chan, nick); + if (m) + killmember(chan, nick); if (msg[0]) putlog(LOG_JOIN, chan->dname, "%s (%s) left %s (%s).", nick, from, chan->dname, msg);