Recast: fix stack corruption caused by out-of-scope variable usage

pmin and pmax pointed to these stack arrays, but these stack arrays were inside the loop while pmin and pmax, along with their usages were outside the scope of the loop causing undefined behavior when they pointed to the currently out-of-scope stack variables. Moved the arrays outside the loop so they remain valid up to the last point they are needed.
This commit is contained in:
Kawe Mazidjatari 2024-09-02 15:40:29 +02:00
parent 3e56daf398
commit ec741313c2

View File

@ -626,6 +626,9 @@ static bool createPolyMeshCells(const dtNavMeshCreateParams* params, rdTempVecto
{
bool onlyBoundary = false;
float storage[3][3];
const float* v[3];
float dmin = FLT_MAX;
float tmin = 0;
const float* pmin = 0;
@ -643,9 +646,6 @@ static bool createPolyMeshCells(const dtNavMeshCreateParams* params, rdTempVecto
if (onlyBoundary && (tris[3] & ANY_BOUNDARY_EDGE) == 0)
continue;
float storage[3][3];
const float* v[3];
for (int m = 0; m < 3; ++m)
{
if (tris[m] < nv)