about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-03-02 21:35:00 +0000
committerJames Booth <boothj5@gmail.com>2013-03-02 21:35:00 +0000
commit18b615c62f214768dfdbd523b4245e1c4763786e (patch)
treec45a2e4b8efc180ca28c5277e553dd445643a082 /src/xmpp
parentaeb0bfa13c81241b14b97234e90b702d357e949a (diff)
downloadprofani-tty-18b615c62f214768dfdbd523b4245e1c4763786e.tar.gz
Check for NULL connection and context
fixes #155
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/connection.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 4120fd99..cf721a85 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -173,10 +173,14 @@ jabber_disconnect(void)
         _connection_free_saved_account();
         _connection_free_saved_details();
         _connection_free_session_data();
-        xmpp_conn_release(jabber_conn.conn);
-        jabber_conn.conn = NULL;
-        xmpp_ctx_free(jabber_conn.ctx);
-        jabber_conn.ctx = NULL;
+        if (jabber_conn.conn != NULL) {
+            xmpp_conn_release(jabber_conn.conn);
+            jabber_conn.conn = NULL;
+        }
+        if (jabber_conn.ctx != NULL) {
+            xmpp_ctx_free(jabber_conn.ctx);
+            jabber_conn.ctx = NULL;
+        }
     }
 
     jabber_conn.conn_status = JABBER_STARTED;
@@ -388,7 +392,15 @@ _jabber_connect(const char * const fulljid, const char * const passwd,
         xmpp_ctx_free(jabber_conn.ctx);
     }
     jabber_conn.ctx = xmpp_ctx_new(NULL, jabber_conn.log);
+    if (jabber_conn.ctx == NULL) {
+        log_warning("Failed to get libstrophe ctx during connect");
+        return JABBER_DISCONNECTED;
+    }
     jabber_conn.conn = xmpp_conn_new(jabber_conn.ctx);
+    if (jabber_conn.conn == NULL) {
+        log_warning("Failed to get libstrophe conn during connect");
+        return JABBER_DISCONNECTED;
+    }
     xmpp_conn_set_jid(jabber_conn.conn, fulljid);
     xmpp_conn_set_pass(jabber_conn.conn, passwd);
     if (jabber_conn.tls_disabled) {