about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorPaul Fertser <fercerpav@gmail.com>2022-10-21 16:28:30 +0200
committerMichael Vetter <jubalh@iodoru.org>2022-10-21 16:28:30 +0200
commit6a47266f0beeb363a8d8145c0479040773fd84b5 (patch)
treedf9353eb840edc692cb32831b5b00387e052d5dc
parenta74a3a4312ea449a6c8affdbce0edfa590d9cc7b (diff)
downloadprofani-tty-6a47266f0beeb363a8d8145c0479040773fd84b5.tar.gz
Fix GSList handling in new MAM code
This patch was provided by @paulfertser and applied by @jubalh.
Thanks a lot Paul!
-rw-r--r--src/xmpp/iq.c21
1 files 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);
     }
 
 
d=4c13e1f2d85483e026d79ab05da9f1e8e4b45293'>4c13e1f2 ^
4e9450f9 ^
34a60763 ^
4c13e1f2 ^
4e9450f9 ^
4c13e1f2 ^
















34a60763 ^







f07bb12f ^

4c13e1f2 ^

34a60763 ^



f07bb12f ^




34a60763 ^




f07bb12f ^












34a60763 ^
4c13e1f2 ^




f07bb12f ^






34a60763 ^
f07bb12f ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129