Recast: add bounds check for sweepscan indices

Only happens on extremely large and complex geometry.
This commit is contained in:
Kawe Mazidjatari 2024-10-13 14:39:52 +02:00
parent 248a652a15
commit c9c687fc73

View File

@ -1425,6 +1425,15 @@ bool rcBuildRegionsMonotone(rcContext* ctx, rcCompactHeightfield& chf,
if (!previd)
{
previd = rid++;
// todo(amos): figure out why this happens on very complex and large
// input geometry.
if (previd >= nsweeps)
{
ctx->log(RC_LOG_ERROR, "rcBuildLayerRegions: Sweep index out of bounds: previd (%d), nsweeps (%d).", previd, nsweeps);
return false;
}
sweeps[previd].rid = previd;
sweeps[previd].ns = 0;
sweeps[previd].nei = 0;
@ -1734,6 +1743,15 @@ bool rcBuildLayerRegions(rcContext* ctx, rcCompactHeightfield& chf,
if (!previd)
{
previd = rid++;
// todo(amos): figure out why this happens on very complex and large
// input geometry.
if (previd >= nsweeps)
{
ctx->log(RC_LOG_ERROR, "rcBuildLayerRegions: Sweep index out of bounds: previd (%d), nsweeps (%d).", previd, nsweeps);
return false;
}
sweeps[previd].rid = previd;
sweeps[previd].ns = 0;
sweeps[previd].nei = 0;