Make sur we always return even length
This commit is contained in:
parent
c413c3a855
commit
2165b38379
|
@ -107,6 +107,7 @@ unsigned int CFMNetwork::read(unsigned char* data, unsigned int space)
|
||||||
{
|
{
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
|
|
||||||
|
|
||||||
unsigned int bytes = m_buffer.dataSize();
|
unsigned int bytes = m_buffer.dataSize();
|
||||||
if (bytes == 0U)
|
if (bytes == 0U)
|
||||||
return 0U;
|
return 0U;
|
||||||
|
@ -114,6 +115,10 @@ unsigned int CFMNetwork::read(unsigned char* data, unsigned int space)
|
||||||
if (bytes < space)
|
if (bytes < space)
|
||||||
space = bytes;
|
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);
|
m_buffer.getData(data, space);
|
||||||
|
|
||||||
return space;
|
return space;
|
||||||
|
|
Loading…
Reference in a new issue