Skip to content

Commit

Permalink
Fix possible FPE (Zero Divide)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandube authored and rndi committed Jul 4, 2019
1 parent 2ecd6b1 commit 08dd7be
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion srtcore/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ void CSndBuffer::updInputRate(uint64_t time, int pkts, int bytes)
m_iInRateBytesCount += bytes;
if ((time - m_InRateStartTime) > m_InRatePeriod) {
//Payload average size
m_iAvgPayloadSz = m_iInRateBytesCount / m_iInRatePktsCount;
if (m_iInRatePktsCount == 0) {
m_iAvgPayloadSz = 0;
}else{
m_iAvgPayloadSz = m_iInRateBytesCount / m_iInRatePktsCount;
}
//Required Byte/sec rate (payload + headers)
m_iInRateBytesCount += (m_iInRatePktsCount * CPacket::SRT_DATA_HDR_SIZE);
m_iInRateBps = (int)(((int64_t)m_iInRateBytesCount * 1000000) / (time - m_InRateStartTime));
Expand Down

0 comments on commit 08dd7be

Please sign in to comment.