Refactor logic which checks for too large allocations

It's now easier to change the limit
This commit is contained in:
Turo Lamminen
2015-08-13 13:01:49 +03:00
parent 5575a54466
commit 0b0ba2ec4d
4 changed files with 15 additions and 5 deletions

View File

@@ -785,7 +785,9 @@ void MD3Importer::InternReadFile( const std::string& pFile,
pScene->mNumMeshes = pcHeader->NUM_SURFACES;
if (pcHeader->NUM_SURFACES == 0) {
throw DeadlyImportError("MD3: No surfaces");
} else if (pcHeader->NUM_SURFACES > std::numeric_limits<int32_t>::max() / sizeof(aiMesh)) {
} else if (pcHeader->NUM_SURFACES > AI_MAX_ALLOC(aiMesh)) {
// We allocate pointers but check against the size of aiMesh
// since those pointers will eventually have to point to real objects
throw DeadlyImportError("MD3: Too many surfaces, would run out of memory");
}
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes];