diff --git a/FMNetwork.cpp b/FMNetwork.cpp index 91cd1c9..cfe6105 100644 --- a/FMNetwork.cpp +++ b/FMNetwork.cpp @@ -107,6 +107,7 @@ unsigned int CFMNetwork::read(unsigned char* data, unsigned int space) { assert(data != NULL); + unsigned int bytes = m_buffer.dataSize(); if (bytes == 0U) return 0U; @@ -114,6 +115,10 @@ unsigned int CFMNetwork::read(unsigned char* data, unsigned int space) if (bytes < space) space = bytes; + //we store usignedshorts, therefore ensure we always return and even number of data + if(space > 0 && space % 2 != 0) + space--;//round down to multiple of 2 + m_buffer.getData(data, space); return space;