From c90128779fd14b8ad43781ea8e1e98664b1f6621 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 27 Jul 2023 15:11:16 +0200 Subject: [PATCH] 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 --- src/stanza.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/stanza.c b/src/stanza.c index b381a1d..ced649b 100644 --- a/src/stanza.c +++ b/src/stanza.c @@ -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); }