Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fix CRcvBuffer last position in getTimespan_ms(). #2579

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions srtcore/buffer_rcv.cpp
Expand Up @@ -591,14 +591,24 @@ int CRcvBuffer::getTimespan_ms() const
if (m_iMaxPosInc == 0)
return 0;

const int lastpos = incPos(m_iStartPos, m_iMaxPosInc - 1);
// Should not happen if TSBPD is enabled (reading out of order is not allowed).
SRT_ASSERT(m_entries[lastpos].pUnit != NULL);
int lastpos = incPos(m_iStartPos, m_iMaxPosInc - 1);
maxsharabayko marked this conversation as resolved.
Show resolved Hide resolved
// Normally the last position should always be non empty
// if TSBPD is enabled (reading out of order is not allowed).
// However if decryption of the last packet fails, it may be dropped
// from the buffer (AES-GCM), and the position will be empty.
SRT_ASSERT(m_entries[lastpos].pUnit != NULL || m_entries[lastpos].status == EntryState_Drop);
while (m_entries[lastpos].pUnit == NULL)
{
if (lastpos == m_iStartPos)
maxsharabayko marked this conversation as resolved.
Show resolved Hide resolved
break;

lastpos = decPos(lastpos);
}

if (m_entries[lastpos].pUnit == NULL)
return 0;

int startpos = m_iStartPos;

while (m_entries[startpos].pUnit == NULL)
{
if (startpos == lastpos)
Expand Down