1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge pull request #1869 from profanity-im/fix/1868-mam

Fix crash if we don't get `first` stanza during RSM
This commit is contained in:
Michael Vetter 2023-07-18 16:45:40 +02:00 committed by GitHub
commit 69d8c1f96e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 20 deletions

View File

@ -135,6 +135,16 @@
</xmpp:SupportedXep> </xmpp:SupportedXep>
</implements> </implements>
<!-- XEP-0059: Result Set Management -->
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource='https://xmpp.org/extensions/xep-0059.html'/>
<xmpp:status>complete</xmpp:status>
<xmpp:version>1.0</xmpp:version>
<xmpp:since>DEV</xmpp:since>
</xmpp:SupportedXep>
</implements>
<!-- XEP-0060: Publish-Subscribe --> <!-- XEP-0060: Publish-Subscribe -->
<implements> <implements>
<xmpp:SupportedXep> <xmpp:SupportedXep>

View File

@ -2738,29 +2738,31 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
auto_char char* firstid = NULL; auto_char char* firstid = NULL;
xmpp_stanza_t* first = xmpp_stanza_get_child_by_name(set, STANZA_NAME_FIRST); xmpp_stanza_t* first = xmpp_stanza_get_child_by_name(set, STANZA_NAME_FIRST);
firstid = xmpp_stanza_get_text(first); if (first) {
firstid = xmpp_stanza_get_text(first);
// 4.3.2. send same stanza with set,max stanza // 4.3.2. send same stanza with set,max stanza
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
if (data->end_datestr) { if (data->end_datestr) {
free(data->end_datestr); free(data->end_datestr);
data->end_datestr = NULL; data->end_datestr = NULL;
}
xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, data->barejid, data->start_datestr, NULL, firstid, NULL);
MamRsmUserdata* ndata = malloc(sizeof(*ndata));
*ndata = *data;
if (data->end_datestr)
ndata->end_datestr = strdup(data->end_datestr);
if (data->start_datestr)
ndata->start_datestr = strdup(data->start_datestr);
if (data->barejid)
ndata->barejid = strdup(data->barejid);
iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, (ProfIqFreeCallback)_mam_userdata_free, ndata);
iq_send_stanza(iq);
xmpp_stanza_release(iq);
} }
xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, data->barejid, data->start_datestr, NULL, firstid, NULL);
MamRsmUserdata* ndata = malloc(sizeof(*ndata));
*ndata = *data;
if (data->end_datestr)
ndata->end_datestr = strdup(data->end_datestr);
if (data->start_datestr)
ndata->start_datestr = strdup(data->start_datestr);
if (data->barejid)
ndata->barejid = strdup(data->barejid);
iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, (ProfIqFreeCallback)_mam_userdata_free, ndata);
iq_send_stanza(iq);
xmpp_stanza_release(iq);
} }
} }
} }