mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:02:55 +02:00
avoid misaligned pointer deref
This commit is contained in:
parent
6ec91cfa82
commit
6a55e67ce9
1 changed files with 9 additions and 6 deletions
|
@ -49,10 +49,11 @@ struct GPUKTXPayload {
|
||||||
|
|
||||||
// We can't copy the bitset in Texture::Usage in a crossplateform manner
|
// We can't copy the bitset in Texture::Usage in a crossplateform manner
|
||||||
// So serialize it manually
|
// So serialize it manually
|
||||||
*(uint32*)data = _usage._flags.to_ulong();
|
uint32 usageData = _usage._flags.to_ulong();
|
||||||
|
memcpy(data, &usageData, sizeof(uint32));
|
||||||
data += sizeof(uint32);
|
data += sizeof(uint32);
|
||||||
|
|
||||||
*(TextureUsageType*)data = _usageType;
|
memcpy(data, &_usageType, sizeof(TextureUsageType));
|
||||||
data += sizeof(TextureUsageType);
|
data += sizeof(TextureUsageType);
|
||||||
|
|
||||||
return data + PADDING;
|
return data + PADDING;
|
||||||
|
@ -80,7 +81,9 @@ struct GPUKTXPayload {
|
||||||
|
|
||||||
// We can't copy the bitset in Texture::Usage in a crossplateform manner
|
// We can't copy the bitset in Texture::Usage in a crossplateform manner
|
||||||
// So unserialize it manually
|
// So unserialize it manually
|
||||||
_usage = Texture::Usage(*(const uint32*)data);
|
uint32 usageData;
|
||||||
|
memcpy(&usageData, data, sizeof(uint32));
|
||||||
|
_usage = Texture::Usage(usageData);
|
||||||
data += sizeof(uint32);
|
data += sizeof(uint32);
|
||||||
|
|
||||||
_usageType = *(const TextureUsageType*)data;
|
_usageType = *(const TextureUsageType*)data;
|
||||||
|
|
Loading…
Reference in a new issue