mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Avoid unaligned memory access when reading floats and doubles from Packet.
This commit is contained in:
parent
5381308268
commit
1d1415c982
@ -247,7 +247,7 @@ Packet& Packet::operator >>(float& data)
|
|||||||
{
|
{
|
||||||
if (checkSize(sizeof(data)))
|
if (checkSize(sizeof(data)))
|
||||||
{
|
{
|
||||||
data = *reinterpret_cast<const float*>(&m_data[m_readPos]);
|
std::memcpy(&data, &m_data[m_readPos], sizeof(data));
|
||||||
m_readPos += sizeof(data);
|
m_readPos += sizeof(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ Packet& Packet::operator >>(double& data)
|
|||||||
{
|
{
|
||||||
if (checkSize(sizeof(data)))
|
if (checkSize(sizeof(data)))
|
||||||
{
|
{
|
||||||
data = *reinterpret_cast<const double*>(&m_data[m_readPos]);
|
std::memcpy(&data, &m_data[m_readPos], sizeof(data));
|
||||||
m_readPos += sizeof(data);
|
m_readPos += sizeof(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user