Merge pull request #957 from barfowl/reserve_overflow_bugs

Fixed integer overflow bugs for large meshes in PatchTable factories
This commit is contained in:
David G Yu 2017-12-15 14:59:47 -08:00 committed by GitHub
commit dc4948fa75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -67,7 +67,7 @@ EndCapBSplineBasisPatchFactory::EndCapBSplineBasisPatchFactory(
// we typically use 7 patch points for each bspline endcap.
int numPatchPointsExpected = numMaxLevelFaces * 7;
// limits to 100M (=800M bytes) entries for the reserved size.
int numStencilsExpected = std::min(numPatchPointsExpected * 16,
int numStencilsExpected = (int) std::min<long>((long)numPatchPointsExpected * 16,
100*1024*1024);
_vertexStencils->reserve(numPatchPointsExpected, numStencilsExpected);
if (_varyingStencils) {

View File

@ -60,7 +60,7 @@ EndCapGregoryBasisPatchFactory::EndCapGregoryBasisPatchFactory(
int numPatchPointsExpected = numMaxLevelFaces * 20;
// limits to 100M (=800M bytes) entries for the reserved size.
int numStencilsExpected = std::min(numPatchPointsExpected * 16,
int numStencilsExpected = (int) std::min<long>((long)numPatchPointsExpected * 16,
100*1024*1024);
_vertexStencils->reserve(numPatchPointsExpected, numStencilsExpected);
if (_varyingStencils) {

View File

@ -148,7 +148,7 @@ EndCapLegacyGregoryPatchFactory::Finalize(
const int SizePerVertex = 2*maxValence + 1;
PatchTable::VertexValenceTable & vTable = (*vertexValenceTable);
vTable.resize(_refiner.GetNumVerticesTotal() * SizePerVertex);
vTable.resize((long)_refiner.GetNumVerticesTotal() * SizePerVertex);
int vOffset = 0;
int levelLast = _refiner.GetMaxLevel();
@ -158,7 +158,7 @@ EndCapLegacyGregoryPatchFactory::Finalize(
if (i == levelLast) {
int vTableOffset = vOffset * SizePerVertex;
long vTableOffset = vOffset * SizePerVertex;
for (int vIndex = 0; vIndex < level->getNumVertices(); ++vIndex) {
int* vTableEntry = &vTable[vTableOffset];