parser: fix memory leak in error path for depth more than 1
If parser has an unfinished stanza with depth > 1, it can happen that parser->stanza points to a child. Releasing the child doesn't free the parent stanza. Instead of releasing parser->stanza in parser_reset() and parser_free(), find the top most parent and release the whole tree. Also add a test case for this memory leak.
This commit is contained in:
@@ -110,6 +110,10 @@ static void test_stanza_from_string(xmpp_ctx_t *ctx)
|
||||
assert(strcmp(buf, str) == 0);
|
||||
xmpp_free(ctx, buf);
|
||||
xmpp_stanza_release(stanza);
|
||||
|
||||
/* Error path. */
|
||||
stanza = xmpp_stanza_new_from_string(ctx, "<uu><uu>tt");
|
||||
assert(stanza == NULL);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
||||
Reference in New Issue
Block a user