From 20ae4e602ef8db60a7ae46eed587b64ba15a6da6 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Mon, 20 Jun 2016 18:22:12 +0300 Subject: [PATCH] Fix buffer wrapper reading data incorrectly. --- source/Library/Utils/BufferWrapper.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/Library/Utils/BufferWrapper.cpp b/source/Library/Utils/BufferWrapper.cpp index 5c4b607b..e9998a32 100644 --- a/source/Library/Utils/BufferWrapper.cpp +++ b/source/Library/Utils/BufferWrapper.cpp @@ -133,7 +133,7 @@ SQInteger BufferWrapper::ReadShort() sizeof(Int16), m_Buffer->Position(), m_Buffer->Capacity()); } // Read one element from the buffer - const Int16 value = m_Buffer->Cursor< Int16 >(); + const Int16 value = *reinterpret_cast< Int16 * >(&m_Buffer->Cursor()); // Advance the buffer cursor m_Buffer->Advance< Int16 >(1); // Return the requested information @@ -152,7 +152,7 @@ SQInteger BufferWrapper::ReadInt() sizeof(Int32), m_Buffer->Position(), m_Buffer->Capacity()); } // Read one element from the buffer - const Int32 value = m_Buffer->Cursor< Int32 >(); + const Int32 value = *reinterpret_cast< Int32 * >(&m_Buffer->Cursor()); // Advance the buffer cursor m_Buffer->Advance< Int32 >(1); // Return the requested information @@ -171,7 +171,7 @@ SQFloat BufferWrapper::ReadFloat() sizeof(Float32), m_Buffer->Position(), m_Buffer->Capacity()); } // Read one element from the buffer - const Float32 value = m_Buffer->Cursor< Float32 >(); + const Float32 value = *reinterpret_cast< Float32 * >(&m_Buffer->Cursor()); // Advance the buffer cursor m_Buffer->Advance< Float32 >(1); // Return the requested information @@ -190,7 +190,7 @@ Object BufferWrapper::ReadString() sizeof(Int16), m_Buffer->Position(), m_Buffer->Capacity()); } // Read one element from the buffer - Int16 length = m_Buffer->Cursor< Int16 >(); + Int16 length = *reinterpret_cast< Int16 * >(&m_Buffer->Cursor()); // Convert the length to little endian length = ((length >> 8) & 0xFF) | ((length & 0xFF) << 8); // Validate the obtained length