1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

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.
This commit is contained in:
Dmitry Podgorny 2019-08-26 12:46:30 +03:00
parent c100897c9d
commit 8c69d7105b

View File

@ -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); char *pref = prefs_get_string(PREF_STATUSBAR_CHAT);
if (g_strcmp0("user", pref) == 0) { if (g_strcmp0("user", pref) == 0) {
Jid *jidp = jid_create(tab->identifier); 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); jid_destroy(jidp);
} else { } else {
tab->display_name = strdup(tab->identifier); tab->display_name = strdup(tab->identifier);