Skip to content

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
DioxusLabs:mainfrom
CyberspaceDreamn:main
Open

Fix a state corruption bug in 4 TaffyTree member functions that causes a crash on TaffyTree::remove.#1102
CyberspaceDreamn wants to merge 5 commits into
DioxusLabs:mainfrom
CyberspaceDreamn:main

Conversation

@CyberspaceDreamn

@CyberspaceDreamn CyberspaceDreamn commented Aug 14, 2026

Copy link
Copy Markdown

Objective

Remove parents of nodes passed as children to TaffyTree::add_child, TaffyTree::insert_child_at_index, TaffyTree::new_with_children, or TaffyTree::replace_child_at_index to prevent state corruption & an eventual panic.

Fixes #1100

Context

Other functions which edit TaffyTree's hierarchy (ex. TaffyTree::set_children) ensure the parents & children arrays are correctly updated. TaffyTree::add_child & friends have a slight oversight. These functions do not remove the child node from its previous parent's children array, which causes a crash when TaffyTree::remove is 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

…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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant