Skip to content

Commit

Permalink
Fix crash looking up departed channel member
Browse files Browse the repository at this point in the history
Found by: BigBadWouf
Patch by: michaelortmann
Fixes: #1708
  • Loading branch information
michaelortmann authored Dec 1, 2024
1 parent 277ec01 commit ba2052f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/mod/irc.mod/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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);
Expand Down

0 comments on commit ba2052f

Please sign in to comment.