Skip to content

Commit d514ab2

Browse files
committed
Fixes use after free in redo of "Create Custom Bone2D(s) from Node(s)"
Using "queue_free" on the undo of the creation of the Bone2D meant that on the redo the Bone2D was already deleted. Replaced it with "add_do_reference", so when the Action of the undo_redo is destroyed, also destroys the Bone2D.
1 parent 9aed9ec commit d514ab2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

editor/plugins/canvas_item_editor_plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4805,11 +4805,12 @@ void CanvasItemEditor::_popup_callback(int p_op) {
48054805
undo_redo->add_do_method(new_bone, "add_child", n2d);
48064806
undo_redo->add_do_method(n2d, "set_transform", Transform2D());
48074807
undo_redo->add_do_method(this, "_set_owner_for_node_and_children", new_bone, editor_root);
4808+
undo_redo->add_do_reference(new_bone);
48084809

48094810
undo_redo->add_undo_method(new_bone, "remove_child", n2d);
48104811
undo_redo->add_undo_method(n2d_parent, "add_child", n2d);
4812+
undo_redo->add_undo_method(n2d_parent, "remove_child", new_bone);
48114813
undo_redo->add_undo_method(n2d, "set_transform", new_bone->get_transform());
4812-
undo_redo->add_undo_method(new_bone, "queue_free");
48134814
undo_redo->add_undo_method(this, "_set_owner_for_node_and_children", n2d, editor_root);
48144815
}
48154816
undo_redo->commit_action();

0 commit comments

Comments
 (0)