From 370485465422fd4d456a6fe927f7f17f778a1ed7 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 19 Nov 2007 04:51:06 +0000 Subject: [PATCH] add more asserts up the call chain to find the source of pea_ and Gimp's bug --- libtransmission/peer-msgs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index 627e5ca8a..82522fe7f 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -1047,6 +1047,7 @@ static int readBtPiece( tr_peermsgs * msgs, struct evbuffer * inbuf, size_t inlen ) { struct peer_request * req = &msgs->incoming.blockReq; + assert( EVBUFFER_LENGTH(inbuf) >= inlen ); dbgmsg( msgs, "In readBtPiece" ); if( !req->length ) @@ -1068,6 +1069,7 @@ readBtPiece( tr_peermsgs * msgs, struct evbuffer * inbuf, size_t inlen ) const size_t nLeft = req->length - EVBUFFER_LENGTH(msgs->incoming.block); size_t n = MIN( nLeft, inlen ); uint8_t * buf = tr_new( uint8_t, n ); + assert( EVBUFFER_LENGTH(inbuf) >= n ); tr_peerIoReadBytes( msgs->io, inbuf, buf, n ); evbuffer_add( msgs->incoming.block, buf, n ); clientGotBytes( msgs, n );