Skip to content

Commit

Permalink
Fixed: Out-of-bounds array access in duel
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbiely committed Jul 16, 2024
1 parent 0f5a940 commit f19b294
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/perf/duel/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,19 +753,19 @@ void BM_NonECS(picobench::state& state) {

// Create entities.
// We allocate via new to simulate the usual kind of behavior in games
const auto N = (uint32_t)state.user_data();
cnt::darray<IUnit*> units(N);
const auto N = (uint32_t)state.user_data() / 2;
cnt::darray<IUnit*> units(N*2);
{
GAIA_PROF_SCOPE(setup);

GAIA_FOR(N / 2) {
GAIA_FOR(N) {
auto* u = new UnitStatic();
u->p = {0, 100, 0};
u->r = {1, 2, 3, 4};
u->s = {1, 1, 1};
units[i] = u;
}
uint32_t j = N / 2;
uint32_t j = N;
GAIA_FOR(N / 4) {
auto* u = new UnitDynamic1();
u->p = {0, 100, 0};
Expand Down Expand Up @@ -851,6 +851,7 @@ void BM_NonECS(picobench::state& state) {
}
}
}

(void)aliveUnits;

units[0]->updatePosition_verify();
Expand Down

0 comments on commit f19b294

Please sign in to comment.