glTF2: zero out extra space created by padding.

This makes resulting GLB deterministic.
pull/3959/head
Hill Ma 2021-06-15 15:18:20 -07:00
parent a9b29abee6
commit 148b8c66a8
1 changed files with 3 additions and 1 deletions

View File

@ -790,8 +790,10 @@ inline bool Buffer::ReplaceData_joint(const size_t pBufferData_Offset, const siz
inline size_t Buffer::AppendData(uint8_t *data, size_t length) {
size_t offset = this->byteLength;
// Force alignment to 4 bits
Grow((length + 3) & ~3);
size_t paddedLength = (length + 3) & ~3;
Grow(paddedLength);
memcpy(mData.get() + offset, data, length);
memset(mData.get() + offset + length, 0, paddedLength - length);
return offset;
}