diff options
author | Dmitry Podgorny <pasis.ua@gmail.com> | 2013-03-12 21:08:50 +0200 |
---|---|---|
committer | Dmitry Podgorny <pasis.ua@gmail.com> | 2013-03-12 21:08:50 +0200 |
commit | ed2212a0cac573dd90847b954e38eddb591d2223 (patch) | |
tree | 3b463c31716d2ab092dd6e0391e61009cce0c8eb /src/xmpp | |
parent | c89de12b0fff4b7c511ad823b46621fc16836702 (diff) | |
download | profani-tty-ed2212a0cac573dd90847b954e38eddb591d2223.tar.gz |
fixed crash in stanza_create_form when text is NULL
xmpp_stanza_get_text may return NULL. Also fixed memory leak: xmpp_stanza_get_text returns new allocated string and it must be freed by xmpp_free().
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/connection.h | 2 | ||||
-rw-r--r-- | src/xmpp/stanza.c | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h index 3c0c1bff..b5701252 100644 --- a/src/xmpp/connection.h +++ b/src/xmpp/connection.h @@ -25,6 +25,8 @@ #include <strophe.h> +#include "resource.h" + xmpp_conn_t *connection_get_conn(void); xmpp_ctx_t *connection_get_ctx(void); int connection_error_handler(xmpp_conn_t * const conn, diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 8e023430..4ee3badd 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -27,6 +27,7 @@ #include <strophe.h> #include "common.h" +#include "xmpp/connection.h" #include "xmpp/stanza.h" #include "xmpp/capabilities.h" @@ -562,6 +563,7 @@ DataForm * stanza_create_form(xmpp_stanza_t * const stanza) { DataForm *result = NULL; + xmpp_ctx_t *ctx = connection_get_ctx(); xmpp_stanza_t *child = xmpp_stanza_get_children(stanza); @@ -591,7 +593,10 @@ stanza_create_form(xmpp_stanza_t * const stanza) // handle values while (value != NULL) { char *text = xmpp_stanza_get_text(value); - field->values = g_slist_insert_sorted(field->values, strdup(text), (GCompareFunc)octet_compare); + if (text != NULL) { + field->values = g_slist_insert_sorted(field->values, strdup(text), (GCompareFunc)octet_compare); + xmpp_free(ctx, text); + } value = xmpp_stanza_get_next(value); } |