Fix heap-use-after-free when removing a tile in TileSet editor

This commit is contained in:
Haoyu Qiu 2022-11-29 09:22:35 +08:00
parent 55dae30177
commit 4a50f44cd2
1 changed files with 3 additions and 1 deletions

View File

@ -543,11 +543,13 @@ void TileSetAtlasSourceEditor::_update_source_inspector() {
void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() { void TileSetAtlasSourceEditor::_update_fix_selected_and_hovered_tiles() {
// Fix selected. // 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(); TileSelection selected = E->get();
if (!tile_set_atlas_source->has_tile(selected.tile) || !tile_set_atlas_source->has_alternative_tile(selected.tile, selected.alternative)) { if (!tile_set_atlas_source->has_tile(selected.tile) || !tile_set_atlas_source->has_alternative_tile(selected.tile, selected.alternative)) {
selection.erase(E); selection.erase(E);
} }
E = N;
} }
// Fix hovered. // Fix hovered.