Changeset 7172


Ignore:
Timestamp:
Nov 28, 2008, 9:35:01 PM (10 years ago)
Author:
charles
Message:

(libT) fix potential underflow in bandwidth allocation code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bandwidth.c

    r7167 r7172  
    259259        const double pulseCount = ( HISTORY_MSEC - period_msec ) / (double)period_msec;
    260260        const double nextPulseSpeed = desiredSpeed * ( pulseCount + 1 ) - ( currentSpeed * pulseCount );
    261         b->band[dir].bytesLeft = nextPulseSpeed * 1024.0 * period_msec / 1000.0;
     261        b->band[dir].bytesLeft = MAX( 0.0, nextPulseSpeed * 1024.0 * period_msec / 1000.0 );
    262262
    263263#ifdef DEBUG_DIRECTION
Note: See TracChangeset for help on using the changeset viewer.