From eb23946fe74955eca8978e168e5a6fb00eba6e36 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 5 Feb 2018 13:44:19 +0100 Subject: [PATCH] Update XFileParser.cpp Fix alignment for float and double. --- code/XFileParser.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/XFileParser.cpp b/code/XFileParser.cpp index 92d8a579b..76ea71e21 100644 --- a/code/XFileParser.cpp +++ b/code/XFileParser.cpp @@ -1349,20 +1349,20 @@ ai_real XFileParser::ReadFloat() } --mBinaryNumCount; - if( mBinaryFloatSize == 8) - { + if( mBinaryFloatSize == 8) { if( mEnd - mP >= 8) { - ai_real result = (ai_real) (*(double*) mP); + double res; + ::memcpy( &res, mP, 8 ); mP += 8; return result; } else { mP = mEnd; return 0; } - } else - { + } else { if( mEnd - mP >= 4) { - ai_real result = *(ai_real*) mP; + ai_real result; + ::memcpy( &result, mP, 4 ); mP += 4; return result; } else {