From: Dave West Date: Tue, 18 Mar 2008 15:18:14 +0000 (+0000) Subject: Missed one. Only need to use a copy of the context list here and X-Git-Tag: v7.86~2414 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=1d70c160be9a9f3f6e3c211dcfb131563dcc103f;p=citadel.git Missed one. Only need to use a copy of the context list here and traverse it in a safe manner. --- diff --git a/citadel/modules/jabber/xmpp_presence.c b/citadel/modules/jabber/xmpp_presence.c index 5c87cca3c..0855cc898 100644 --- a/citadel/modules/jabber/xmpp_presence.c +++ b/citadel/modules/jabber/xmpp_presence.c @@ -86,15 +86,20 @@ void xmpp_presence_notify(char *presence_jid, int event_type) { struct CitContext *cptr; static int unsolicited_id; int visible_sessions = 0; + int nContexts, i; int aide = (CC->user.axlevel >= 6); if (IsEmptyStr(presence_jid)) return; + cptr = CtdlGetContextArray(&nContexts); + if (!cptr) + return ; /** FIXME: Does jabber need to send something to maintain the protocol? */ + /* Count the visible sessions for this user */ - for (cptr = ContextList; cptr != NULL; cptr = cptr->next) { - if (cptr->logged_in) { - if ( (!strcasecmp(cptr->cs_inet_email, presence_jid)) - && (((cptr->cs_flags&CS_STEALTH)==0) || (aide)) + for (i=0; i logged in\n", CC->cs_pid, presence_jid); /* Do an unsolicited roster update that adds a new contact. */ - for (cptr = ContextList; cptr != NULL; cptr = cptr->next) { - if (cptr->logged_in) { - if (!strcasecmp(cptr->cs_inet_email, presence_jid)) { + for (i=0; i", ++unsolicited_id); cprintf(""); - jabber_roster_item(cptr); + jabber_roster_item(&cptr[i]); cprintf("" ""); } @@ -142,6 +147,7 @@ void xmpp_presence_notify(char *presence_jid, int event_type) { cprintf("" ""); } + free(cptr); }