Skip to content

Commit

Permalink
Fix the memory leak in the new freeing algorithm
Browse files Browse the repository at this point in the history
(cherry picked from commit 09ed8c4)
  • Loading branch information
mrjimenez committed Apr 5, 2021
1 parent af1f8bc commit c279fd3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ixml/src/node.c
Expand Up @@ -139,24 +139,24 @@ void ixmlNode_free(IXML_Node *nodeptr)
if (nodeptr) {
#ifdef IXML_HAVE_SCRIPTSUPPORT
IXML_BeforeFreeNode_t hndlr = Parser_getBeforeFree();
if (hndlr) {
hndlr(nodeptr);
}
#endif
prev_child = nodeptr;
next_child = nodeptr->firstChild;
do {
curr_child = next_child;
while (curr_child) {
do {
while (curr_child) {
prev_child = curr_child;
curr_child = curr_child->firstChild;
}
if (curr_child) {
curr_child = prev_child;
while (curr_child) {
prev_child = curr_child;
curr_child = curr_child->nextSibling;
}
}
curr_child = prev_child;
next_child = curr_child->firstChild;
} while (next_child);
curr_child = prev_child;
/* current is now the last sibling of the last child. */
/* Delete the attribute nodes of this child */
Expand All @@ -178,6 +178,11 @@ void ixmlNode_free(IXML_Node *nodeptr)
next_child->firstChild = 0;
}
}
#ifdef IXML_HAVE_SCRIPTSUPPORT
if (hndlr) {
hndlr(curr_child);
}
#endif
ixmlNode_freeSingleNode(curr_child);
} while (curr_child != nodeptr);
}
Expand Down

0 comments on commit c279fd3

Please sign in to comment.