about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorSteffen Jaeckel <jaeckel-floss@eyet-services.de>2023-05-21 11:02:14 +0200
committerSteffen Jaeckel <jaeckel-floss@eyet-services.de>2023-05-21 11:02:14 +0200
commitb6bb50ceb28250317351fd5115e3f187f0c56fba (patch)
treec6f01f9718a643a1ddb15d02fd2221b647b21107 /src/xmpp
parentc0861eed495e52c5db0b7595b83f2bd4e0585222 (diff)
downloadprofani-tty-b6bb50ceb28250317351fd5115e3f187f0c56fba.tar.gz
Fix use-after-free
introduced in 8d3c1f79ac7cc2b0830f0afed48dc1fb9008ab0e

This fixes #1852

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/iq.c4
1 files changed, 3 insertions, 1 deletions
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);