fix a potential situation where we may get a length stuck on the queue (this shouldn't happen but, this is protection logic to ensure it never happens);

pull/59/head
Bryan Biedenkapp 2 years ago
parent 24082b9652
commit 41044d2271

@ -1044,6 +1044,13 @@ uint32_t Modem::readP25Frame(uint8_t* data)
uint16_t len = 0U;
len = (length[0U] << 8) + length[1U];
// this ensures we never get in a situation where we have length stuck on the queue
if (m_rxP25Queue.dataSize() == 2U && len > m_rxP25Queue.dataSize()) {
m_rxP25Queue.get(length, 2U); // ensure we pop the length off
return 0U;
}
if (m_rxP25Queue.dataSize() >= len) {
m_rxP25Queue.get(length, 2U); // ensure we pop the length off
m_rxP25Queue.get(data, len);

Loading…
Cancel
Save

Powered by TurnKey Linux.