Fix possible bad_alloc exception for invalid file
- Fuzzer finding - closes https://github.com/assimp/assimp/issues/3417pull/4614/head
parent
c1012b4af0
commit
2d994e1a28
|
@ -129,10 +129,20 @@ void Q3DImporter::InternReadFile(const std::string &pFile,
|
||||||
unsigned int numTextures = (unsigned int)stream.GetI4();
|
unsigned int numTextures = (unsigned int)stream.GetI4();
|
||||||
|
|
||||||
std::vector<Material> materials;
|
std::vector<Material> materials;
|
||||||
|
try {
|
||||||
materials.reserve(numMats);
|
materials.reserve(numMats);
|
||||||
|
} catch(const std::bad_alloc& e) {
|
||||||
|
ASSIMP_LOG_ERROR("Invalid alloc for materials.");
|
||||||
|
throw DeadlyImportError("Invalid Quick3D-file, material allocation failed.");
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Mesh> meshes;
|
std::vector<Mesh> meshes;
|
||||||
|
try {
|
||||||
meshes.reserve(numMeshes);
|
meshes.reserve(numMeshes);
|
||||||
|
} catch(const std::bad_alloc& e) {
|
||||||
|
ASSIMP_LOG_ERROR("Invalid alloc for meshes.");
|
||||||
|
throw DeadlyImportError("Invalid Quick3D-file, mesh allocation failed.");
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate the scene root node
|
// Allocate the scene root node
|
||||||
pScene->mRootNode = new aiNode();
|
pScene->mRootNode = new aiNode();
|
||||||
|
|
Loading…
Reference in New Issue