Fix xmpp_stanza_release() for cloned child-stanzas.

Break the linked-list of children before releasing a child.

Before this patch it was possible, when a child is cloned and stored
for longer than the lifetime of its parent, that its `next` pointer
points to invalid memory that was already free'd when the parent stanza
was released.

This issue exists already since the initial version of
`xmpp_stanza_release()`.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel
2023-07-27 15:11:16 +02:00
parent acb8e0f629
commit c90128779f

View File

@@ -182,6 +182,7 @@ int xmpp_stanza_release(xmpp_stanza_t *stanza)
while (child) {
tchild = child;
child = child->next;
tchild->next = NULL;
xmpp_stanza_release(tchild);
}