diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-11-29 09:22:35 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2022-11-29 09:22:35 +0800 |
commit | 4a50f44cd22448474aedc35d96533e8709ba26f7 (patch) | |
tree | 967715d6e0db40bdc72d0b5096791cb7bcfb6fc9 | |
parent | 55dae301777ba609c3255026f9a9852a0dbfd43b (diff) |
Fix heap-use-after-free when removing a tile in TileSet editor
-rw-r--r-- | editor/plugins/tiles/tile_set_atlas_source_editor.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 8e69abd7ff..11007e6851 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -543,11 +543,13 @@ void TileSetAtlasSourceEditor::_update_source_inspector() { void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() { // Fix selected. - for (RBSet<TileSelection>::Element *E = selection.front(); E; E = E->next()) { + for (RBSet<TileSelection>::Element *E = selection.front(); E;) { + RBSet<TileSelection>::Element *N = E->next(); TileSelection selected = E->get(); if (!tile_set_atlas_source->has_tile(selected.tile) || !tile_set_atlas_source->has_alternative_tile(selected.tile, selected.alternative)) { selection.erase(E); } + E = N; } // Fix hovered. |