Merge pull request #15504 from amantley/bugMaxBandwidth

Fixed possible divide by zero error in setPacketSendPeriod()
This commit is contained in:
Shannon Romano 2019-05-03 09:17:32 -07:00 committed by GitHub
commit 74a79d04e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,7 +29,7 @@ void CongestionControl::setMaxBandwidth(int maxBandwidth) {
void CongestionControl::setPacketSendPeriod(double newSendPeriod) {
Q_ASSERT_X(newSendPeriod >= 0, "CongestionControl::setPacketPeriod", "Can not set a negative packet send period");
auto packetsPerSecond = (double)_maxBandwidth / (BITS_PER_BYTE * _mss);
auto packetsPerSecond = _mss > 0 ? (double)_maxBandwidth / (BITS_PER_BYTE * _mss) : -1.0;
if (packetsPerSecond > 0.0) {
// anytime the packet send period is about to be increased, make sure it stays below the minimum period,
// calculated based on the maximum desired bandwidth