Merge pull request #3394 from ms-maxvollmer/gltfBufferViewSizeFix

GLTF2: Throw instead of assert when input file is invalid.
pull/3405/head
Kim Kulling 2020-09-23 21:22:14 +02:00 committed by GitHub
commit 22dd53a4a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {