Merge pull request #3068 from ms-maxvollmer/GLTF2_invalid_buffer_fix

GLTF2: ExtractData now throws exception instead of returning false if data is invalid
pull/3070/head^2
Kim Kulling 2020-04-16 11:28:38 +02:00 committed by GitHub
commit 1e74fe85bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -375,8 +375,8 @@ struct Accessor : public Object {
inline uint8_t *GetPointer();
template <class T>
bool ExtractData(T *&outData);
template<class T>
void ExtractData(T *&outData);
void WriteData(size_t count, const void *src_buffer, size_t src_stride);

View File

@ -613,10 +613,13 @@ inline void CopyData(size_t count,
}
} // namespace
template <class T>
bool Accessor::ExtractData(T *&outData) {
uint8_t *data = GetPointer();
if (!data) return false;
template<class T>
void Accessor::ExtractData(T *&outData)
{
uint8_t* data = GetPointer();
if (!data) {
throw DeadlyImportError("GLTF: data is NULL");
}
const size_t elemSize = GetElementSize();
const size_t totalSize = elemSize * count;
@ -636,8 +639,6 @@ bool Accessor::ExtractData(T *&outData) {
memcpy(outData + i, data + i * stride, elemSize);
}
}
return true;
}
inline void Accessor::WriteData(size_t _count, const void *src_buffer, size_t src_stride) {