1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00

Check for NULL connection and context

fixes #155
This commit is contained in:
James Booth 2013-03-02 21:35:00 +00:00
parent aeb0bfa13c
commit 18b615c62f

View File

@ -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) {