mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
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().
This commit is contained in:
parent
c89de12b0f
commit
ed2212a0ca
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include <strophe.h>
|
#include <strophe.h>
|
||||||
|
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
xmpp_conn_t *connection_get_conn(void);
|
xmpp_conn_t *connection_get_conn(void);
|
||||||
xmpp_ctx_t *connection_get_ctx(void);
|
xmpp_ctx_t *connection_get_ctx(void);
|
||||||
int connection_error_handler(xmpp_conn_t * const conn,
|
int connection_error_handler(xmpp_conn_t * const conn,
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <strophe.h>
|
#include <strophe.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "xmpp/connection.h"
|
||||||
#include "xmpp/stanza.h"
|
#include "xmpp/stanza.h"
|
||||||
#include "xmpp/capabilities.h"
|
#include "xmpp/capabilities.h"
|
||||||
|
|
||||||
@ -562,6 +563,7 @@ DataForm *
|
|||||||
stanza_create_form(xmpp_stanza_t * const stanza)
|
stanza_create_form(xmpp_stanza_t * const stanza)
|
||||||
{
|
{
|
||||||
DataForm *result = NULL;
|
DataForm *result = NULL;
|
||||||
|
xmpp_ctx_t *ctx = connection_get_ctx();
|
||||||
|
|
||||||
xmpp_stanza_t *child = xmpp_stanza_get_children(stanza);
|
xmpp_stanza_t *child = xmpp_stanza_get_children(stanza);
|
||||||
|
|
||||||
@ -591,7 +593,10 @@ stanza_create_form(xmpp_stanza_t * const stanza)
|
|||||||
// handle values
|
// handle values
|
||||||
while (value != NULL) {
|
while (value != NULL) {
|
||||||
char *text = xmpp_stanza_get_text(value);
|
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);
|
value = xmpp_stanza_get_next(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user