Fixed too large memory alloc in rcBuildPolyMesh.

This commit is contained in:
Mikko Mononen 2010-01-10 17:16:33 +00:00
parent c897eaedb8
commit 44b6c54c57

View File

@ -823,13 +823,14 @@ bool rcBuildPolyMesh(rcContourSet& cset, int nvp, rcPolyMesh& mesh)
rcGetLog()->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.polys' (%d).", maxTris*nvp*2); rcGetLog()->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.polys' (%d).", maxTris*nvp*2);
return false; return false;
} }
mesh.regs = new unsigned short[maxTris*2]; mesh.regs = new unsigned short[maxTris];
if (!mesh.regs) if (!mesh.regs)
{ {
if (rcGetLog()) if (rcGetLog())
rcGetLog()->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.regs' (%d).", maxTris); rcGetLog()->log(RC_LOG_ERROR, "rcBuildPolyMesh: Out of memory 'mesh.regs' (%d).", maxTris);
return false; return false;
} }
mesh.nverts = 0; mesh.nverts = 0;
mesh.npolys = 0; mesh.npolys = 0;
mesh.nvp = nvp; mesh.nvp = nvp;