Skip to content

Commit

Permalink
Properly handle nodes being replaced when fixing comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
weetmuts committed Dec 18, 2023
1 parent f519c72 commit ae22cbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions dist/xmq.c
Original file line number Diff line number Diff line change
Expand Up @@ -4987,8 +4987,9 @@ void xmq_fixup_html_before_writeout(XMQDoc *doq)

while (i)
{
xmlNode *next = xml_next_sibling(i); // i might be freed in fixup_html.
fixup_html(doq, i, false);
i = xml_next_sibling(i);
i = next;
}
}

Expand All @@ -5015,7 +5016,6 @@ void fixup_comments(XMQDoc *doq, xmlNode *node)
while (i)
{
xmlNode *next = xml_next_sibling(i); // i might be freed in trim.

fixup_comments(doq, i);
i = next;
}
Expand All @@ -5028,8 +5028,9 @@ void xmq_fixup_comments_after_readin(XMQDoc *doq)

while (i)
{
xmlNode *next = xml_next_sibling(i); // i might be freed in fixup_comments.
fixup_comments(doq, i);
i = xml_next_sibling(i);
i = next;
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/main/c/xmq.c
Original file line number Diff line number Diff line change
Expand Up @@ -4211,8 +4211,9 @@ void xmq_fixup_html_before_writeout(XMQDoc *doq)

while (i)
{
xmlNode *next = xml_next_sibling(i); // i might be freed in fixup_html.
fixup_html(doq, i, false);
i = xml_next_sibling(i);
i = next;
}
}

Expand All @@ -4239,7 +4240,6 @@ void fixup_comments(XMQDoc *doq, xmlNode *node)
while (i)
{
xmlNode *next = xml_next_sibling(i); // i might be freed in trim.

fixup_comments(doq, i);
i = next;
}
Expand All @@ -4252,8 +4252,9 @@ void xmq_fixup_comments_after_readin(XMQDoc *doq)

while (i)
{
xmlNode *next = xml_next_sibling(i); // i might be freed in fixup_comments.
fixup_comments(doq, i);
i = xml_next_sibling(i);
i = next;
}
}

Expand Down

0 comments on commit ae22cbd

Please sign in to comment.