Merge pull request #3068 from ms-maxvollmer/GLTF2_invalid_buffer_fix
GLTF2: ExtractData now throws exception instead of returning false if data is invalidpull/3070/head^2
commit
1e74fe85bf
|
@ -375,8 +375,8 @@ struct Accessor : public Object {
|
||||||
|
|
||||||
inline uint8_t *GetPointer();
|
inline uint8_t *GetPointer();
|
||||||
|
|
||||||
template <class T>
|
template<class T>
|
||||||
bool ExtractData(T *&outData);
|
void ExtractData(T *&outData);
|
||||||
|
|
||||||
void WriteData(size_t count, const void *src_buffer, size_t src_stride);
|
void WriteData(size_t count, const void *src_buffer, size_t src_stride);
|
||||||
|
|
||||||
|
|
|
@ -613,10 +613,13 @@ inline void CopyData(size_t count,
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
template <class T>
|
template<class T>
|
||||||
bool Accessor::ExtractData(T *&outData) {
|
void Accessor::ExtractData(T *&outData)
|
||||||
uint8_t *data = GetPointer();
|
{
|
||||||
if (!data) return false;
|
uint8_t* data = GetPointer();
|
||||||
|
if (!data) {
|
||||||
|
throw DeadlyImportError("GLTF: data is NULL");
|
||||||
|
}
|
||||||
|
|
||||||
const size_t elemSize = GetElementSize();
|
const size_t elemSize = GetElementSize();
|
||||||
const size_t totalSize = elemSize * count;
|
const size_t totalSize = elemSize * count;
|
||||||
|
@ -636,8 +639,6 @@ bool Accessor::ExtractData(T *&outData) {
|
||||||
memcpy(outData + i, data + i * stride, elemSize);
|
memcpy(outData + i, data + i * stride, elemSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Accessor::WriteData(size_t _count, const void *src_buffer, size_t src_stride) {
|
inline void Accessor::WriteData(size_t _count, const void *src_buffer, size_t src_stride) {
|
||||||
|
|
Loading…
Reference in New Issue