diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-03 12:24:10 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-03 12:24:10 +0100 |
commit | 2a57a5e63f97b7f028754b0b475035d115ed9ac3 (patch) | |
tree | 7d007b0457a02f2590523368388a72a76ef268d1 | |
parent | 1f53579a8f1a6934fd7ccc3c47e9eb6e2fdeb00f (diff) | |
parent | 1ac35c38be336207ac7a8df7a769efe6e0a09ba4 (diff) |
Merge pull request #70732 from timothyqiu/tilemap-crash
Fix heap-use-after-free when using TileMap editor
-rw-r--r-- | editor/plugins/tiles/tile_map_editor.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 5a1f214933..414c3a2759 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -1488,13 +1488,15 @@ void TileMapEditorTilesPlugin::_update_fix_selected_and_hovered() { } // Selection if needed. - for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E; E = E->next()) { + for (RBSet<TileMapCell>::Element *E = tile_set_selection.front(); E;) { + RBSet<TileMapCell>::Element *N = E->next(); const TileMapCell *selected = &(E->get()); if (!tile_set->has_source(selected->source_id) || !tile_set->get_source(selected->source_id)->has_tile(selected->get_atlas_coords()) || !tile_set->get_source(selected->source_id)->has_alternative_tile(selected->get_atlas_coords(), selected->alternative_tile)) { tile_set_selection.erase(E); } + E = N; } if (!tile_map_selection.is_empty()) { |