1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

message: fix possible segfault in _handle_conference

This commit is contained in:
Michael Vetter 2021-03-25 11:43:42 +01:00
parent f21a99eaf8
commit 96b228728e

View File

@ -931,29 +931,33 @@ _handle_conference(xmpp_stanza_t* const stanza)
{
xmpp_stanza_t* xns_conference = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CONFERENCE);
const char* from = xmpp_stanza_get_from(stanza);
if (!from) {
log_warning("Message received with no from attribute, ignoring");
return;
}
if (xns_conference) {
Jid* jidp = jid_create(from);
if (!jidp) {
return;
}
const char* from = xmpp_stanza_get_from(stanza);
if (!from) {
log_warning("Message received with no from attribute, ignoring");
return;
}
// XEP-0249
const char* room = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_JID);
if (!room) {
Jid* jidp = jid_create(from);
if (!jidp) {
return;
}
// XEP-0249
const char* room = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_JID);
if (!room) {
jid_destroy(jidp);
return;
}
// reason and password are both optional
const char* reason = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_REASON);
const char* password = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_PASSWORD);
sv_ev_room_invite(INVITE_DIRECT, jidp->barejid, room, reason, password);
jid_destroy(jidp);
return;
}
const char* reason = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_REASON);
const char* password = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_PASSWORD);
sv_ev_room_invite(INVITE_DIRECT, jidp->barejid, room, reason, password);
jid_destroy(jidp);
}
static void