Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
InsertEndChild,InsertFirstChild, andInsertAfterChildwhile preserving valid existing-node moves.Bug
The shared insertion preamble previously verified document ownership and then immediately unlinked an existing node. It did not verify that the proposed child was the destination node itself or an ancestor of it. Relinking such a node creates a cycle in the DOM. Recursive operations such as
Accept,DeepClone, XML printing, and document destruction can then exhaust the stack.This includes the self-insertion case reported in #915 and the broader strict-ancestor case. It is separate from the adjacent-child
InsertAfterChildissue handled by #1103; this change does not alter that case.Fix
Before any unlinking or allocation tracking, walk from the proposed parent through its
_parentchain. If the node being inserted is encountered, return null without modifying either tree. The check lives in the shared insertion preamble used by all three insertion APIs.Tests
Regression tests cover, for each insertion API:
Accept;DeepCloneand printing after rejection;Validation with GCC 16.2.1:
xmltest: Pass 549, Fail 0;xmltest(TINYXML2_DEBUG): Pass 549, Fail 0;xmltest: Pass 549, Fail 0, no diagnostics;xmltest: Pass 549, Fail 0, no diagnostics;