mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-05 22:19:43 +00:00
Merge branch 'fix_ub' into 'master'
Fix UB: reference binding to misaligned address in Lua tests See merge request OpenMW/openmw!1025
This commit is contained in:
commit
e5dc8e1ec9
1 changed files with 4 additions and 2 deletions
|
@ -163,7 +163,8 @@ namespace
|
|||
{
|
||||
if (sizeof(TestStruct1) != binaryData.size())
|
||||
throw std::runtime_error("Incorrect binaryData.size() for TestStruct1: " + std::to_string(binaryData.size()));
|
||||
TestStruct1 t = *reinterpret_cast<const TestStruct1*>(binaryData.data());
|
||||
TestStruct1 t;
|
||||
std::memcpy(&t, binaryData.data(), sizeof(t));
|
||||
t.a = Misc::fromLittleEndian(t.a);
|
||||
t.b = Misc::fromLittleEndian(t.b);
|
||||
sol::stack::push<TestStruct1>(lua, t);
|
||||
|
@ -173,7 +174,8 @@ namespace
|
|||
{
|
||||
if (sizeof(TestStruct2) != binaryData.size())
|
||||
throw std::runtime_error("Incorrect binaryData.size() for TestStruct2: " + std::to_string(binaryData.size()));
|
||||
TestStruct2 t = *reinterpret_cast<const TestStruct2*>(binaryData.data());
|
||||
TestStruct2 t;
|
||||
std::memcpy(&t, binaryData.data(), sizeof(t));
|
||||
t.a = Misc::fromLittleEndian(t.a);
|
||||
t.b = Misc::fromLittleEndian(t.b);
|
||||
sol::stack::push<TestStruct2>(lua, t);
|
||||
|
|
Loading…
Reference in a new issue