mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 02:57:10 +02:00
Merge pull request #13113 from sethalves/fix-ktx-asan-warning
avoid misaligned pointer deref in ktx code
This commit is contained in:
commit
14f4c035ab
1 changed files with 10 additions and 7 deletions
|
@ -49,10 +49,11 @@ struct GPUKTXPayload {
|
|||
|
||||
// We can't copy the bitset in Texture::Usage in a crossplateform manner
|
||||
// So serialize it manually
|
||||
*(uint32*)data = _usage._flags.to_ulong();
|
||||
uint32 usageData = _usage._flags.to_ulong();
|
||||
memcpy(data, &usageData, sizeof(uint32));
|
||||
data += sizeof(uint32);
|
||||
|
||||
*(TextureUsageType*)data = _usageType;
|
||||
memcpy(data, &_usageType, sizeof(TextureUsageType));
|
||||
data += sizeof(TextureUsageType);
|
||||
|
||||
return data + PADDING;
|
||||
|
@ -80,10 +81,12 @@ struct GPUKTXPayload {
|
|||
|
||||
// We can't copy the bitset in Texture::Usage in a crossplateform manner
|
||||
// So unserialize it manually
|
||||
_usage = Texture::Usage(*(const uint32*)data);
|
||||
uint32 usageData;
|
||||
memcpy(&usageData, data, sizeof(uint32));
|
||||
_usage = Texture::Usage(usageData);
|
||||
data += sizeof(uint32);
|
||||
|
||||
_usageType = *(const TextureUsageType*)data;
|
||||
memcpy(&_usageType, data, sizeof(TextureUsageType));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue