Recast: fix heap buffer overflow during link remap [ASAN]

Polyrefs may become invalid as we remove dead polygons and reindex the remainders. If the polyref is invalid, skip the link as it will be thrown out anyways. Issue was found using address sanitizer on level mp_rr_desertlands_64k_x_64k.
This commit is contained in:
Kawe Mazidjatari 2024-10-16 19:43:17 +02:00
parent 9b44b098f8
commit d5116913d6

View File

@ -1647,6 +1647,9 @@ bool dtUpdateNavMeshData(dtNavMesh* nav, const unsigned int tileIndex)
if (it != tileIndex)
continue;
if (salt != tile->salt || ip >= (unsigned int)header->polyCount)
continue;
const dtPolyRef newRef = (polyRefBase | (dtPolyRef)newPolyIdMap[ip]);
neiLink.ref = newRef;