Update STLLoader.cpp

Fix memory-alignment bug.
This commit is contained in:
Kim Kulling
2017-11-07 10:42:51 +01:00
committed by GitHub
parent 4ff2592747
commit b87e7643d2

View File

@@ -80,7 +80,9 @@ static bool IsBinarySTL(const char* buffer, unsigned int fileSize) {
return false;
}
const uint32_t faceCount = *reinterpret_cast<const uint32_t*>(buffer + 80);
char *facecount_pos = buffer + 80;
uint32_t faceCount( 0 );
::memcpy( &faceCount, facecount_pos, sizeof( uint32_t ) );
const uint32_t expectedBinaryFileSize = faceCount * 50 + 84;
return expectedBinaryFileSize == fileSize;