Make muc_nick return a const char* const

In the documentation of the `muc_nick` function we can read:

> The nickname is owned by the chat room and should not be modified or freed

We should reflect that in the return type and `strdup` the value for the
plugin API.

Fixes: https://github.com/profanity-im/profanity/issues/2013
This commit is contained in:
Hanspeter Portner
2025-01-19 13:21:31 +01:00
parent baddf2a8da
commit cb395b7c09
11 changed files with 23 additions and 18 deletions

View File

@@ -307,7 +307,7 @@ void
groupchat_log_msg_out(const gchar* const room, const gchar* const msg)
{
if (prefs_get_boolean(PREF_GRLOG)) {
char* mynick = muc_nick(room);
const char* const mynick = muc_nick(room);
_groupchat_log_chat(connection_get_barejid(), room, mynick, msg);
}
}
@@ -326,7 +326,7 @@ groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg)
if (prefs_get_boolean(PREF_CHLOG)) {
const char* mybarejid = connection_get_barejid();
auto_gchar gchar* pref_omemo_log = prefs_get_string(PREF_OMEMO_LOG);
char* mynick = muc_nick(room);
const char* const mynick = muc_nick(room);
if (strcmp(pref_omemo_log, "on") == 0) {
_groupchat_log_chat(mybarejid, room, mynick, msg);