examples/bot: fixed memory leak
This commit is contained in:
@@ -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);
|
replytext = malloc(strlen(" to you too!") + strlen(intext) + 1);
|
||||||
strcpy(replytext, intext);
|
strcpy(replytext, intext);
|
||||||
strcat(replytext, " to you too!");
|
strcat(replytext, " to you too!");
|
||||||
|
xmpp_free(ctx, intext);
|
||||||
|
|
||||||
text = xmpp_stanza_new(ctx);
|
text = xmpp_stanza_new(ctx);
|
||||||
xmpp_stanza_set_text(text, replytext);
|
xmpp_stanza_set_text(text, replytext);
|
||||||
xmpp_stanza_add_child(body, text);
|
xmpp_stanza_add_child(body, text);
|
||||||
xmpp_stanza_add_child(reply, body);
|
xmpp_stanza_add_child(reply, body);
|
||||||
|
xmpp_stanza_release(body);
|
||||||
|
xmpp_stanza_release(text);
|
||||||
|
|
||||||
xmpp_send(conn, reply);
|
xmpp_send(conn, reply);
|
||||||
xmpp_stanza_release(reply);
|
xmpp_stanza_release(reply);
|
||||||
|
|||||||
Reference in New Issue
Block a user