mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-16 15:30:25 +01:00
Fix aliasing violation when reading primitives
This commit is contained in:
parent
ad9fda174f
commit
d4eea38a65
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -111,7 +111,7 @@ jobs:
|
|||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -DCMAKE_BUILD_TYPE=Release ..
|
||||
cmake -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/g++-5 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-Werror" ..
|
||||
cmake --build .
|
||||
cd ..
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <tiny_gltf.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -76,7 +77,9 @@ static T readPrimitive(const BufferOffset& readFrom)
|
|||
for (std::size_t i = 0; i < sizeof(T); ++i) {
|
||||
d[i] = readFrom.at(i);
|
||||
}
|
||||
return *reinterpret_cast<T*>(d);
|
||||
T dest;
|
||||
std::memcpy(&dest, d, sizeof(dest));
|
||||
return dest;
|
||||
}
|
||||
|
||||
static core::vector2df readVec2DF(const BufferOffset& readFrom)
|
||||
|
|
Loading…
Reference in New Issue
Block a user