Fix a state corruption bug in 4 TaffyTree member functions that causes a crash on TaffyTree::remove. - #1102
Open
CyberspaceDreamn wants to merge 5 commits into
Open
Fix a state corruption bug in 4 TaffyTree member functions that causes a crash on TaffyTree::remove.#1102CyberspaceDreamn wants to merge 5 commits into
TaffyTree member functions that causes a crash on TaffyTree::remove.#1102CyberspaceDreamn wants to merge 5 commits into
Conversation
…ild` or `TaffyTree::insert_child_at_index` with a `NodeId` that already has a parent.
…add_child` & `TaffyTree::insert_child_at_index`
…hat could cause a crash when later calling `TaffyTree::remove`
…ould crash when later calling `TaffyTree::remove`.
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.
Objective
Remove parents of nodes passed as children to
TaffyTree::add_child,TaffyTree::insert_child_at_index,TaffyTree::new_with_children, orTaffyTree::replace_child_at_indexto prevent state corruption & an eventual panic.Fixes #1100
Context
Other functions which edit
TaffyTree's hierarchy (ex.TaffyTree::set_children) ensure theparents&childrenarrays are correctly updated.TaffyTree::add_child& friends have a slight oversight. These functions do not remove the child node from its previous parent'schildrenarray, which causes a crash whenTaffyTree::removeis called.Demo code in a gist because the extra 60 lines of code in a description is a bit much.
https://gist.github.com/CyberspaceDreamn/674cb5331fb962773299e20ce6162f9f