examples/bot: fixed memory leak

This commit is contained in:
Dmitry Podgorny
2015-10-23 00:40:13 +03:00
parent 2aea1a627c
commit a54def3e92

View File

@@ -87,11 +87,14 @@ int message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void
replytext = malloc(strlen(" to you too!") + strlen(intext) + 1);
strcpy(replytext, intext);
strcat(replytext, " to you too!");
xmpp_free(ctx, intext);
text = xmpp_stanza_new(ctx);
xmpp_stanza_set_text(text, replytext);
xmpp_stanza_add_child(body, text);
xmpp_stanza_add_child(reply, body);
xmpp_stanza_release(body);
xmpp_stanza_release(text);
xmpp_send(conn, reply);
xmpp_stanza_release(reply);