mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-24 01:25:41 +08:00
Make sur we always return even length
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user