about summary refs log tree commit diff stats
path: root/src/xmpp/connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp/connection.c')
-rw-r--r--src/xmpp/connection.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index c5475258..d601de22 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -747,6 +747,8 @@ connection_get_ctx(void)
 const char*
 connection_get_fulljid(void)
 {
+    if (!conn.xmpp_conn)
+        return NULL;
     const char* jid = xmpp_conn_get_bound_jid(conn.xmpp_conn);
     if (jid) {
         return jid;
@@ -759,10 +761,11 @@ char*
 connection_get_barejid(void)
 {
     const char* jid = connection_get_fulljid();
-    char* result;
+    if (!jid)
+        return NULL;
 
     Jid* jidp = jid_create(jid);
-    result = strdup(jidp->barejid);
+    char* result = strdup(jidp->barejid);
     jid_destroy(jidp);
 
     return result;
@@ -772,8 +775,9 @@ char*
 connection_get_user(void)
 {
     const char* jid = connection_get_fulljid();
-    char* result;
-    result = strdup(jid);
+    if (!jid)
+        return NULL;
+    char* result = strdup(jid);
 
     char* split = strchr(result, '@');
     *split = '\0';