Skip to content

Commit

Permalink
fix(memory): prevent double destruction on AnyVector::swapErase
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Mar 20, 2024
1 parent 7df4b9f commit c692ed3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Wrong tranform gizmo position for entities with parents (#1003, **@DiogoMendonc-a**).
- Free camera controller angle not being bounded (#1016, **@diogomsmiranda**).
- Crash when meshing an empty voxel grid (**@RiscadoA**).
- Double destruction in AnyVector::swapErase (**@RiscadoA**).

## [v0.1.0] - 2024-02-17

Expand Down
7 changes: 5 additions & 2 deletions core/src/memory/any_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,12 @@ void AnyVector::swapErase(std::size_t index)
// If the element isn't the last one, we move the last element to its place.
mConstructibleTrait->moveConstruct(static_cast<char*>(mData) + mStride * index,
static_cast<char*>(mData) + mStride * (mSize - 1));
this->pop();
}
else
{
--mSize;
}

this->pop();
}

void AnyVector::swapMove(std::size_t index, void* destination)
Expand Down

0 comments on commit c692ed3

Please sign in to comment.