Make sur we always return even length
This commit is contained in:
parent
c413c3a855
commit
2165b38379
1 changed files with 5 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue