B3DImporter: Replace bad pointer casting with memcpy
authorTuro Lamminen <turotl@gmail.com>
Sat, 7 Oct 2017 15:36:09 +0000 (18:36 +0300)
committerTuro Lamminen <turotl@gmail.com>
Sat, 14 Oct 2017 15:46:19 +0000 (18:46 +0300)
code/B3DImporter.cpp

index d156761..bc888fb 100644 (file)
@@ -171,7 +171,8 @@ int B3DImporter::ReadByte(){
 // ------------------------------------------------------------------------------------------------
 int B3DImporter::ReadInt(){
     if( _pos+4<=_buf.size() ){
-        int n=*(int*)&_buf[_pos];
+        int n;
+        memcpy(&n, &_buf[_pos], 4);
         _pos+=4;
         return n;
     }
@@ -182,7 +183,8 @@ int B3DImporter::ReadInt(){
 // ------------------------------------------------------------------------------------------------
 float B3DImporter::ReadFloat(){
     if( _pos+4<=_buf.size() ){
-        float n=*(float*)&_buf[_pos];
+        float n;
+        memcpy(&n, &_buf[_pos], 4);
         _pos+=4;
         return n;
     }