about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-03-09 16:33:42 +0100
committerMichael Vetter <jubalh@iodoru.org>2020-03-09 16:33:42 +0100
commit7e62d458ee22e9171bf5741cda5c8ce85b20bd6a (patch)
tree34467e0231328955a5cf94494e619daa199adec8
parenta23d4e4af7c10f6762577940a12983903bf4428d (diff)
downloadprofani-tty-7e62d458ee22e9171bf5741cda5c8ce85b20bd6a.tar.gz
Make statusbar tab more resilient
If users input strange stuff and we can't create a jid from it even the
setting is set to 'user' we still should fallback to the regular
identifer.

For example with `/msg @name%matrix.domain.org@matrix.org hi`.
-rw-r--r--src/ui/statusbar.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c
index c3b7c7b4..82fa5c66 100644
--- a/src/ui/statusbar.c
+++ b/src/ui/statusbar.c
@@ -199,10 +199,14 @@ _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 = jidp->localpart != NULL ?
-						strdup(jidp->localpart) :
-						strdup(jidp->barejid);
-                jid_destroy(jidp);
+                if (jidp) {
+                    tab->display_name = jidp->localpart != NULL ?
+                        strdup(jidp->localpart) :
+                        strdup(jidp->barejid);
+                    jid_destroy(jidp);
+                } else {
+                    tab->display_name = strdup(tab->identifier);
+                }
             } else {
                 tab->display_name = strdup(tab->identifier);
             }