Fix heap corruption when collecting region layers

The collecting could overflow the neighbours array due to a missing boundary
check.

Fix #30
This commit is contained in:
Jakob Botsch Nielsen 2016-01-02 13:33:27 +01:00
parent d6ab8fdf86
commit c1f9fd8406

View File

@ -258,7 +258,7 @@ bool rcBuildHeightfieldLayers(rcContext* ctx, rcCompactHeightfield& chf,
const int ay = y + rcGetDirOffsetY(dir);
const int ai = (int)chf.cells[ax+ay*w].index + rcGetCon(s, dir);
const unsigned char rai = srcReg[ai];
if (rai != 0xff && rai != ri)
if (rai != 0xff && rai != ri && regs[ri].nneis < RC_MAX_NEIS)
addUnique(regs[ri].neis, regs[ri].nneis, rai);
}
}