Skip to content

Commit

Permalink
#951 Fix issue where id record could get deleted twice during world c…
Browse files Browse the repository at this point in the history
…leanup
  • Loading branch information
SanderMertens committed May 9, 2023
1 parent 350f1aa commit 4ec5292
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -60863,8 +60863,12 @@ void flecs_init_id_records(
void flecs_fini_id_records(
ecs_world_t *world)
{
ecs_map_iter_t it = ecs_map_iter(&world->id_index_hi);
while (ecs_map_next(&it)) {
/* Loop & delete first element until there are no elements left. Id records
* can recursively delete each other, this ensures we always have a
* valid iterator. */
while (ecs_map_count(&world->id_index_hi) > 0) {
ecs_map_iter_t it = ecs_map_iter(&world->id_index_hi);
ecs_map_next(&it);
flecs_id_record_release(world, ecs_map_ptr(&it));
}

Expand Down
8 changes: 6 additions & 2 deletions src/id_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,12 @@ void flecs_init_id_records(
void flecs_fini_id_records(
ecs_world_t *world)
{
ecs_map_iter_t it = ecs_map_iter(&world->id_index_hi);
while (ecs_map_next(&it)) {
/* Loop & delete first element until there are no elements left. Id records
* can recursively delete each other, this ensures we always have a
* valid iterator. */
while (ecs_map_count(&world->id_index_hi) > 0) {
ecs_map_iter_t it = ecs_map_iter(&world->id_index_hi);
ecs_map_next(&it);
flecs_id_record_release(world, ecs_map_ptr(&it));
}

Expand Down

0 comments on commit 4ec5292

Please sign in to comment.