From 8c69d7105b310ba34295cbdcbd4167fac731e649 Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Mon, 26 Aug 2019 12:46:30 +0300 Subject: Don't crash if source jid doesn't contain the node part Profanity uses the node part of a JID as display name for a tab. If such a JID doesn't contain the node part, Profanity crashes on NULL pointer dereference. In the above case, use barejid which is just a domain. Fixes #1153. --- src/ui/statusbar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 495b79ab..4ad1e373 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -198,7 +198,9 @@ _create_tab(const int win, win_type_t wintype, char *identifier, gboolean highli char *pref = prefs_get_string(PREF_STATUSBAR_CHAT); if (g_strcmp0("user", pref) == 0) { Jid *jidp = jid_create(tab->identifier); - tab->display_name = strdup(jidp->localpart); + tab->display_name = jidp->localpart != NULL ? + strdup(jidp->localpart) : + strdup(jidp->barejid); jid_destroy(jidp); } else { tab->display_name = strdup(tab->identifier); -- cgit 1.4.1-2-gfad0