What: Throw instead of assert when input file is invalid.

Why: Assimp shouldn't crash on invalid files. Asserts are disabled on Release builds.
pull/3394/head
Max Vollmer 2020-09-10 10:47:58 +01:00
parent 4f30b2aa5c
commit 615ffdf93f
1 changed files with 8 additions and 2 deletions

View File

@ -731,8 +731,14 @@ void Accessor::ExtractData(T *&outData) {
const size_t stride = bufferView && bufferView->byteStride ? bufferView->byteStride : elemSize;
const size_t targetElemSize = sizeof(T);
ai_assert(elemSize <= targetElemSize);
ai_assert(count * stride <= (bufferView ? bufferView->byteLength : sparse->data.size()));
if (elemSize > targetElemSize) {
throw DeadlyImportError("GLTF: elemSize > targetElemSize");
}
if (count*stride > (bufferView ? bufferView->byteLength : sparse->data.size())) {
throw DeadlyImportError("GLTF: count*stride out of range");
}
outData = new T[count];
if (stride == elemSize && targetElemSize == elemSize) {