metajack / libstrophe

The libstrophe repository has moved to https://github.com/strophe/libstrophe
http://strophe.im/libstrophe
Other
135 stars 49 forks source link

libstrophe leaks memory #28

Open cizra opened 12 years ago

cizra commented 12 years ago

After adding this patch:

diff --git a/examples/bot.c b/examples/bot.c
index 03ba9c8..8ace449 100644
--- a/examples/bot.c
+++ b/examples/bot.c
@@ -90,6 +90,11 @@ int message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void

        body = xmpp_stanza_new(ctx);
        xmpp_stanza_set_name(body, "body");
+
+       if (strcmp(intext, "end") == 0) {
+               xmpp_stop(ctx);
+               return 1;
+       }

        replytext = malloc(strlen(" to you too!") + strlen(intext) + 1);
        strcpy(replytext, intext);

.. I tested the bot, and thus libstrophe, for memory leaks with Valgrind. Valgrind reports lots of leaks. The patches submitted in issues #27, #26, #18 didn't help much.

Here's the Valgrind log of the leaks: https://gist.github.com/3317999