From 574b413bef1591b85d0fc2466ccb2ff9c271ec5f Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 23 Oct 2024 08:54:45 +0800 Subject: [PATCH] Fix heap-use-after-free when ctrl-clicking controls in a container --- editor/plugins/canvas_item_editor_plugin.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index e9a796dae723..05d5f6836312 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1464,10 +1464,12 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref &p_event) { List selection = _get_edited_canvas_items(false, true, &has_locked_items); // Remove not movable nodes - for (CanvasItem *E : selection) { - if (!_is_node_movable(E, true)) { + for (List::Element *E = selection.front(); E;) { + List::Element *N = E->next(); + if (!_is_node_movable(E->get(), true)) { selection.erase(E); } + E = N; } drag_selection = selection;