mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +01:00
Fix NPE in Roster if 'from' is null
This commit is contained in:
parent
a53894a65b
commit
e3dced6eea
1 changed files with 10 additions and 4 deletions
|
@ -1233,10 +1233,13 @@ public final class Roster extends Manager {
|
||||||
final XMPPConnection connection = connection();
|
final XMPPConnection connection = connection();
|
||||||
Presence presence = (Presence) packet;
|
Presence presence = (Presence) packet;
|
||||||
Jid from = presence.getFrom();
|
Jid from = presence.getFrom();
|
||||||
Resourcepart fromResource = from.getResourceOrNull();
|
Resourcepart fromResource = Resourcepart.EMPTY;
|
||||||
|
if (from != null) {
|
||||||
|
fromResource = from.getResourceOrNull();
|
||||||
if (fromResource == null) {
|
if (fromResource == null) {
|
||||||
fromResource = Resourcepart.EMPTY;
|
fromResource = Resourcepart.EMPTY;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Jid key = getMapKey(from);
|
Jid key = getMapKey(from);
|
||||||
Map<Resourcepart, Presence> userPresences;
|
Map<Resourcepart, Presence> userPresences;
|
||||||
Presence response = null;
|
Presence response = null;
|
||||||
|
@ -1313,7 +1316,10 @@ public final class Roster extends Manager {
|
||||||
// Error presence packets from a bare JID mean we invalidate all existing
|
// Error presence packets from a bare JID mean we invalidate all existing
|
||||||
// presence info for the user.
|
// presence info for the user.
|
||||||
case error:
|
case error:
|
||||||
if (!from.isBareJid()) {
|
// No need to act on error presences send without from, i.e.
|
||||||
|
// directly send from the users XMPP service, or where the from
|
||||||
|
// address is not a bare JID
|
||||||
|
if (from == null || !from.isBareJid()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
userPresences = getUserPresences(key);
|
userPresences = getUserPresences(key);
|
||||||
|
|
Loading…
Reference in a new issue