Comparison

plugins/muc/muc.lib.lua @ 4424:1cbf3744300c

MUC: Fix a possible stack overflow (when a local component joins a room, then disconnects, an unavailble-error presence cycle can occur).
author Waqas Hussain <waqas20@gmail.com>
date Mon, 21 Nov 2011 19:59:38 +0500
parent 4357:d6928b78c548
child 4528:875b90d5ce0f
comparison
equal deleted inserted replaced
4418:70b5e533325d 4424:1cbf3744300c
356 self:handle_to_occupant(origin, build_unavailable_presence_from_error(stanza)); 356 self:handle_to_occupant(origin, build_unavailable_presence_from_error(stanza));
357 end 357 end
358 elseif type == "unavailable" then -- unavailable 358 elseif type == "unavailable" then -- unavailable
359 if current_nick then 359 if current_nick then
360 log("debug", "%s leaving %s", current_nick, room); 360 log("debug", "%s leaving %s", current_nick, room);
361 self._jid_nick[from] = nil;
361 local occupant = self._occupants[current_nick]; 362 local occupant = self._occupants[current_nick];
362 local new_jid = next(occupant.sessions); 363 local new_jid = next(occupant.sessions);
363 if new_jid == from then new_jid = next(occupant.sessions, new_jid); end 364 if new_jid == from then new_jid = next(occupant.sessions, new_jid); end
364 if new_jid then 365 if new_jid then
365 local jid = occupant.jid; 366 local jid = occupant.jid;
380 else 381 else
381 occupant.role = 'none'; 382 occupant.role = 'none';
382 self:broadcast_presence(pr, from); 383 self:broadcast_presence(pr, from);
383 self._occupants[current_nick] = nil; 384 self._occupants[current_nick] = nil;
384 end 385 end
385 self._jid_nick[from] = nil;
386 end 386 end
387 elseif not type then -- available 387 elseif not type then -- available
388 if current_nick then 388 if current_nick then
389 --if #pr == #stanza or current_nick ~= to then -- commented because google keeps resending directed presence 389 --if #pr == #stanza or current_nick ~= to then -- commented because google keeps resending directed presence
390 if current_nick == to then -- simple presence 390 if current_nick == to then -- simple presence