Kaynağa Gözat

Fix heap-use-after-free when changing 2D editor selection

Haoyu Qiu 8 ay önce
ebeveyn
işleme
577f90feba
1 değiştirilmiş dosya ile 5 ekleme ve 3 silme
  1. 5 3
      editor/plugins/canvas_item_editor_plugin.cpp

+ 5 - 3
editor/plugins/canvas_item_editor_plugin.cpp

@@ -3659,10 +3659,12 @@ void CanvasItemEditor::_draw_selection() {
 	}
 
 	// Remove non-movable nodes.
-	for (CanvasItem *ci : selection) {
-		if (!_is_node_movable(ci)) {
-			selection.erase(ci);
+	for (List<CanvasItem *>::Element *E = selection.front(); E;) {
+		List<CanvasItem *>::Element *N = E->next();
+		if (!_is_node_movable(E->get())) {
+			selection.erase(E);
 		}
+		E = N;
 	}
 
 	if (!selection.is_empty() && transform_tool && show_transformation_gizmos) {