mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-13 14:00:27 +01:00
Fix aliasing violation when reading primitives
This commit is contained in:
parent
3dc24abdb3
commit
47a195b4de
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -153,7 +153,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