From 6a47266f0beeb363a8d8145c0479040773fd84b5 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Fri, 21 Oct 2022 16:28:30 +0200 Subject: Fix GSList handling in new MAM code This patch was provided by @paulfertser and applied by @jubalh. Thanks a lot Paul! --- src/xmpp/iq.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 4c1ec90b..8eff3f5d 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -269,8 +269,6 @@ iq_handlers_init(void) id_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_iq_id_handler_free); rooms_cache = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)xmpp_stanza_release); - late_delivery_windows = malloc(sizeof(GSList *)); - late_delivery_windows->data = NULL; } void @@ -2541,12 +2539,12 @@ _disco_items_result_handler(xmpp_stanza_t* const stanza) received_disco_items = TRUE; connection_set_disco_items(items); - while (late_delivery_windows->data) { + while (late_delivery_windows) { LateDeliveryUserdata* del_data = late_delivery_windows->data; _iq_mam_request(del_data->win, del_data->startdate, del_data->enddate); - - late_delivery_windows = g_slist_next(late_delivery_windows); free(del_data); + late_delivery_windows = g_slist_delete_link(late_delivery_windows, + late_delivery_windows); } } @@ -2702,14 +2700,11 @@ iq_mam_request(ProfChatWin* win, GDateTime* enddate) // Save request for later if disco items haven't been received yet if (!received_disco_items) { - if (late_delivery_windows->data == NULL) { - LateDeliveryUserdata* cur_del_data = malloc(sizeof(LateDeliveryUserdata)); - cur_del_data->win = win; - cur_del_data->enddate = enddate; - cur_del_data->startdate = startdate; - late_delivery_windows->data = cur_del_data; - } - late_delivery_windows = g_slist_append(late_delivery_windows, NULL); + LateDeliveryUserdata* cur_del_data = malloc(sizeof(LateDeliveryUserdata)); + cur_del_data->win = win; + cur_del_data->enddate = enddate; + cur_del_data->startdate = startdate; + late_delivery_windows = g_slist_append(late_delivery_windows, cur_del_data); } -- cgit 1.4.1-2-gfad0