diff options
author | Joshua Colp <jcolp@digium.com> | 2017-03-24 10:46:34 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-03-24 10:46:34 -0500 |
commit | 6666deb9078ef5db13c5e4ea8923e412e30b3db5 (patch) | |
tree | bf48585b7b44be9b0348514b951999fc580669f6 /res/res_xmpp.c | |
parent | 1a626ffb898e05fa3dee56d92c4346c3c3c0db38 (diff) | |
parent | 7657c279b592b40fc6922122c3c3954b118a0ec7 (diff) |
Merge "res_xmpp: Don't crash when trying to send a message without a connection"
Diffstat (limited to 'res/res_xmpp.c')
-rw-r--r-- | res/res_xmpp.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/res/res_xmpp.c b/res/res_xmpp.c index 6abfdbc60..b4def93a0 100644 --- a/res/res_xmpp.c +++ b/res/res_xmpp.c @@ -2562,10 +2562,16 @@ static void xmpp_log_hook(void *data, const char *xmpp, size_t size, int incomin static int xmpp_client_send_raw_message(struct ast_xmpp_client *client, const char *message) { int ret; -#ifdef HAVE_OPENSSL - int len = strlen(message); + if (client->state == XMPP_STATE_DISCONNECTED) { + /* iks_send_raw will crash without a connection */ + return IKS_NET_NOCONN; + } + +#ifdef HAVE_OPENSSL if (xmpp_is_secure(client)) { + int len = strlen(message); + ret = SSL_write(client->ssl_session, message, len); if (ret) { /* Log the message here, because iksemel's logHook is |