1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

ox: dont print empty body message

Fix https://github.com/profanity-im/profanity/issues/1693

```
@StefanKropp @DebXWoody please check `_handle_ox_chat()` I don't
understand what you are doing there.
1)
First plain is assigned `message->plain =
p_ox_gpg_decrypt(xmpp_stanza_get_text(ox));`
and then in the same if block you overwrite this with `message->plain =
xmpp_stanza_get_text(b);` without freeing the old value as far as I can
see.

2)
Sometimes even doing `message->plain = "OX error: No payload found";`.
Shouldn't there be a `strdup()`? I think later on we try to free the
whole message struct. So we can't mix this static things.
```
This commit is contained in:
Michael Vetter 2022-04-27 17:00:30 +02:00
parent 196fdd9cb9
commit 2dc0cc489c

View File

@ -1452,12 +1452,13 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c
// 0085 works only with resource // 0085 works only with resource
if (jid->resourcepart) { if (jid->resourcepart) {
// XEP-0085: Chat State Notifications // XEP-0085: Chat Stase Notifications
_handle_chat_states(stanza, jid); _handle_chat_states(stanza, jid);
} }
message_free(message); message_free(message);
} }
static void static void
_handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_mam) _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_mam)
{ {
@ -1478,8 +1479,7 @@ _handle_ox_chat(xmpp_stanza_t* const stanza, ProfMessage* message, gboolean is_m
} }
xmpp_stanza_t* b = xmpp_stanza_get_child_by_name(p, "body"); xmpp_stanza_t* b = xmpp_stanza_get_child_by_name(p, "body");
if (!b) { if (!b) {
log_warning("OX Stanza - no body"); log_debug("OX Stanza - no body");
message->plain = "OX error: No payload body found";
return; return;
} }
message->plain = xmpp_stanza_get_text(b); message->plain = xmpp_stanza_get_text(b);