Merge pull request #523 from turol/afl-fixes

More crash fixes
This commit is contained in:
Kim Kulling
2015-06-22 16:56:51 +02:00
6 changed files with 24 additions and 7 deletions

View File

@@ -284,6 +284,9 @@ void AC3DImporter::LoadObjectSection(std::vector<Object>& objects)
SkipSpaces(&buffer);
unsigned int t = strtoul10(buffer,&buffer);
if (t >= std::numeric_limits<int32_t>::max() / sizeof(aiVector3D)) {
throw DeadlyImportError("AC3D: Too many vertices, would run out of memory");
}
obj.vertices.reserve(t);
for (unsigned int i = 0; i < t;++i)
{
@@ -608,6 +611,9 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
face.mIndices[i] = cur++;
// copy vertex positions
if ((vertices - mesh->mVertices) >= mesh->mNumVertices) {
throw DeadlyImportError("AC3D: Invalid number of vertices");
}
*vertices = object.vertices[entry.first] + object.translation;
@@ -639,6 +645,10 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
face.mIndices[1] = cur++;
// copy vertex positions
if (it2 == (*it).entries.end() ) {
throw DeadlyImportError("AC3D: Bad line");
}
ai_assert((*it2).first < object.vertices.size());
*vertices++ = object.vertices[(*it2).first];
// copy texture coordinates