about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2023-05-28 12:03:11 +0200
committerGitHub <noreply@github.com>2023-05-28 12:03:11 +0200
commit796fb6d1ffcc7fb478ae383996d1d26b278a9820 (patch)
treec6f01f9718a643a1ddb15d02fd2221b647b21107
parent879525c61b8ec540279a58cffe19dd2fab668c2f (diff)
parentb6bb50ceb28250317351fd5115e3f187f0c56fba (diff)
downloadprofani-tty-796fb6d1ffcc7fb478ae383996d1d26b278a9820.tar.gz
Merge pull request #1853 from profanity-im/fix-1852
Fix 1852
-rw-r--r--src/xmpp/iq.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c
index eb72178d..f56e78e6 100644
--- a/src/xmpp/iq.c
+++ b/src/xmpp/iq.c
@@ -1615,6 +1615,7 @@ _version_get_handler(xmpp_stanza_t* const stanza)
     const char* from = xmpp_stanza_get_from(stanza);
     ProfAccount* account = accounts_get_account(session_get_account_name());
     auto_char char* client = account->client != NULL ? strdup(account->client) : NULL;
+    account_free(account);
     bool is_custom_client = client != NULL;
     gchar* custom_version_str = NULL;
     if (is_custom_client) {
@@ -2727,9 +2728,11 @@ iq_mam_request(ProfChatWin* win, GDateTime* enddate)
     if (!received_disco_items) {
         LateDeliveryUserdata* cur_del_data = malloc(sizeof(LateDeliveryUserdata));
         cur_del_data->win = win;
-        cur_del_data->enddate = g_date_time_ref(enddate);
-        cur_del_data->startdate = g_date_time_ref(startdate);
+        cur_del_data->enddate = enddate;
+        cur_del_data->startdate = startdate;
         late_delivery_windows = g_slist_append(late_delivery_windows, cur_del_data);
+        log_debug("Save MAM request of %s for later", win->barejid);
+        return;
     }
 
     _iq_mam_request(win, startdate, enddate);
@@ -2793,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);