commit fd45b94

grunfink  ·  2025-12-18 07:41:28 +0000 UTC
parent c8ee70f
Fixed leak in timeline_admire().
2 files changed,  +6, -5
M data.c
M snac.h
M data.c
+4, -3
 1@@ -1567,9 +1567,10 @@ int timeline_add(snac *snac, const char *id, const xs_dict *o_msg)
 2 }
 3 
 4 
 5-int timeline_emoji_react(const char *act, const char *id, xs_dict *msg)
 6+int timeline_emoji_react(const char *act, const char *id, const xs_dict *msg_o)
 7 /* adds an emoji reaction to a message */
 8 {
 9+    xs *msg = xs_dup(msg_o);
10     msg = xs_dict_append(msg, "attributedTo", act);
11     msg = xs_dict_set(msg, "type", "EmojiReact");
12     const char *emote_id = xs_dict_get(msg, "id");
13@@ -1583,7 +1584,7 @@ int timeline_emoji_react(const char *act, const char *id, xs_dict *msg)
14 
15 
16 int timeline_admire(snac *snac, const char *id,
17-                    const char *admirer, int like, xs_dict *msg)
18+                    const char *admirer, int like, const xs_dict *msg)
19 /* updates a timeline entry with a new admiration or emoji reaction */
20 {
21     int ret;
22@@ -1599,7 +1600,7 @@ int timeline_admire(snac *snac, const char *id,
23     /* use utf <3 as a like, as it is ugly */
24     if (type && xs_match(type, "Like|EmojiReact|Emoji") &&
25             content && strcmp(content, "❤") != 0) {
26-        ret = timeline_emoji_react(snac->actor, id, xs_dup(msg));
27+        ret = timeline_emoji_react(snac->actor, id, msg);
28         snac_debug(snac, 1, xs_fmt("timeline_emoji_react %s", id));
29     }
30 
M snac.h
+2, -2
 1@@ -183,8 +183,8 @@ xs_str *user_index_fn(snac *user, const char *idx_name);
 2 xs_list *timeline_simple_list(snac *user, const char *idx_name, int skip, int show, int *more);
 3 xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show, int *more);
 4 int timeline_add(snac *snac, const char *id, const xs_dict *o_msg);
 5-int timeline_admire(snac *snac, const char *id, const char *admirer, int like, xs_dict *msg);
 6-int timeline_emoji_react(const char *atto, const char *id, xs_dict *o_msg);
 7+int timeline_admire(snac *snac, const char *id, const char *admirer, int like, const xs_dict *msg);
 8+int timeline_emoji_react(const char *atto, const char *id, const xs_dict *o_msg);
 9 
10 xs_list *timeline_top_level(snac *snac, const xs_list *list);
11 void timeline_add_mark(snac *user);