Merge pull request #69323 from timothyqiu/erase-in-loop

Fix heap-use-after-free when removing a tile in TileSet editor
This commit is contained in:
Rémi Verschelde 2022-11-29 10:26:57 +01:00
commit a3e39d7e7c
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -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.