From f2d9179b64da02e95adc76911cb922b927e73bee Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 30 Dec 2008 03:45:12 +0000 Subject: [PATCH] (trunk libT) #1632: bandwidth.c: 428: tr_bandwidthUsed: Assertion `tr_isBandwidth( b )' failed --- libtransmission/peer-io.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libtransmission/peer-io.c b/libtransmission/peer-io.c index 23cba89b8..d44458233 100644 --- a/libtransmission/peer-io.c +++ b/libtransmission/peer-io.c @@ -153,6 +153,8 @@ canReadWrapper( tr_peerIo * io ) tr_bool err = 0; tr_session * session = io->session; + assert( tr_isPeerIo( io ) ); + dbgmsg( io, "canRead" ); /* try to consume the input buffer */ @@ -168,11 +170,16 @@ canReadWrapper( tr_peerIo * io ) const size_t used = oldLen - EVBUFFER_LENGTH( io->inbuf ); - if( piece ) - tr_bandwidthUsed( io->bandwidth, TR_DOWN, piece, TRUE ); + assert( tr_isPeerIo( io ) ); - if( used != piece ) - tr_bandwidthUsed( io->bandwidth, TR_DOWN, used - piece, FALSE ); + if( io->bandwidth != NULL ) + { + if( piece ) + tr_bandwidthUsed( io->bandwidth, TR_DOWN, piece, TRUE ); + + if( used != piece ) + tr_bandwidthUsed( io->bandwidth, TR_DOWN, used - piece, FALSE ); + } switch( ret ) {