From 6e6093ee7b6a70ec91c96c822900e9f808647a51 Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Tue, 12 Sep 2017 17:43:05 +0300 Subject: [PATCH] stanza: fix xmpp_error_new() in #115 * Don't set text to a tag stanza. It returns XMPP_INVOP. * Don't use stanza after releasing own reference. --- src/stanza.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stanza.c b/src/stanza.c index 4c399f1..76e8f40 100644 --- a/src/stanza.c +++ b/src/stanza.c @@ -1321,14 +1321,14 @@ xmpp_stanza_t *xmpp_error_new(xmpp_ctx_t *ctx, xmpp_error_type_t const type, cha xmpp_stanza_t *error_text = xmpp_stanza_new(ctx); xmpp_stanza_set_name(error_text, "text"); xmpp_stanza_set_ns(error_text, XMPP_NS_STREAMS_IETF); - xmpp_stanza_set_text(error_text, text); - xmpp_stanza_add_child(error, error_text); - xmpp_stanza_release(error_text); xmpp_stanza_t *content = xmpp_stanza_new(ctx); xmpp_stanza_set_text(content, text); xmpp_stanza_add_child(error_text, content); xmpp_stanza_release(content); + + xmpp_stanza_add_child(error, error_text); + xmpp_stanza_release(error_text); } return error;