(libT) fix potential underflow in bandwidth allocation code

This commit is contained in:
Charles Kerr 2008-11-28 21:35:01 +00:00
parent ca433d44ae
commit b3c4061b1c
1 changed files with 1 additions and 1 deletions

View File

@ -258,7 +258,7 @@ tr_bandwidthAllocate( tr_bandwidth * b,
const double desiredSpeed = b->band[dir].desiredSpeed;
const double pulseCount = ( HISTORY_MSEC - period_msec ) / (double)period_msec;
const double nextPulseSpeed = desiredSpeed * ( pulseCount + 1 ) - ( currentSpeed * pulseCount );
b->band[dir].bytesLeft = nextPulseSpeed * 1024.0 * period_msec / 1000.0;
b->band[dir].bytesLeft = MAX( 0.0, nextPulseSpeed * 1024.0 * period_msec / 1000.0 );
#ifdef DEBUG_DIRECTION
if( dir == DEBUG_DIRECTION )