1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 03:12:44 +00:00

(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

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 )