From 3838e5a98231fc2ea886661a379acb038f91c55f Mon Sep 17 00:00:00 2001 From: John Hernandez <129467592+H3rnand3zzz@users.noreply.github.com> Date: Sun, 15 Oct 2023 23:24:13 +0200 Subject: [PATCH] Fix crash on reconnection in the chat window Profanity tries to access the nickname from the roster, but roster is being cleaned already, thus leading to use-after-free. Fix #1894 https://github.com/profanity-im/profanity/issues/1894 --- src/ui/window.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ui/window.c b/src/ui/window.c index f75e7d06..730859d2 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -312,7 +312,10 @@ win_get_title(ProfWin* window) { const ProfChatWin* chatwin = (ProfChatWin*)window; assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK); - const PContact contact = roster_get_contact(chatwin->barejid); + PContact contact = NULL; + if (roster_exists()) { + contact = roster_get_contact(chatwin->barejid); + } if (!contact) { return g_strdup(chatwin->barejid); }