mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-21 04:46:22 +00:00
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:
@@ -231,7 +231,8 @@ api_get_current_nick(void)
|
||||
if (current->type == WIN_MUC) {
|
||||
ProfMucWin* mucwin = (ProfMucWin*)current;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
return muc_nick(mucwin->roomjid);
|
||||
const char* const nick = muc_nick(mucwin->roomjid);
|
||||
return nick ? strdup(nick) : NULL;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
@@ -286,7 +287,9 @@ api_current_win_is_console(void)
|
||||
char*
|
||||
api_get_room_nick(const char* barejid)
|
||||
{
|
||||
return muc_nick(barejid);
|
||||
const char* const nick = muc_nick(barejid);
|
||||
|
||||
return nick ? strdup(nick) : NULL;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -435,7 +435,9 @@ python_api_get_current_nick(PyObject* self, PyObject* args)
|
||||
char* nick = api_get_current_nick();
|
||||
disable_python_threads();
|
||||
if (nick) {
|
||||
return Py_BuildValue("s", nick);
|
||||
PyObject* obj = Py_BuildValue("s", nick);
|
||||
free(nick);
|
||||
return obj;
|
||||
} else {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user