From b6bb50ceb28250317351fd5115e3f187f0c56fba Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sun, 21 May 2023 11:02:14 +0200 Subject: Fix use-after-free introduced in 8d3c1f79ac7cc2b0830f0afed48dc1fb9008ab0e This fixes #1852 Signed-off-by: Steffen Jaeckel --- src/xmpp/iq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/xmpp') diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index a9285425..f56e78e6 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -2796,7 +2796,9 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata) xmpp_stanza_t* iq = stanza_create_mam_iq(ctx, data->barejid, data->start_datestr, NULL, firstid, NULL); free(firstid); - iq_id_handler_add(xmpp_stanza_get_id(iq), _mam_rsm_id_handler, (ProfIqFreeCallback)_mam_userdata_free, data); + MamRsmUserdata* ndata = malloc(sizeof(*ndata)); + *ndata = *data; + 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); -- cgit 1.4.1-2-gfad0