mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
(trunk, libt) #4932 'crash on magnet links' -- fixed.
This commit is contained in:
parent
8096c12fe0
commit
624c8ff1cc
3 changed files with 19 additions and 8 deletions
|
@ -271,8 +271,12 @@ void *
|
|||
tr_cpCreatePieceBitfield( const tr_completion * cp, size_t * byte_count )
|
||||
{
|
||||
void * ret;
|
||||
tr_piece_index_t n;
|
||||
tr_bitfield pieces;
|
||||
const tr_piece_index_t n = cp->tor->info.pieceCount;
|
||||
|
||||
assert( tr_torrentHasMetadata( cp->tor ) );
|
||||
|
||||
n = cp->tor->info.pieceCount;
|
||||
tr_bitfieldConstruct( &pieces, n );
|
||||
|
||||
if( tr_cpHasAll( cp ) )
|
||||
|
|
|
@ -1984,10 +1984,13 @@ gotError( tr_peerIo * io UNUSED, short what, void * vmsgs )
|
|||
static void
|
||||
sendBitfield( tr_peermsgs * msgs )
|
||||
{
|
||||
void * bytes;
|
||||
size_t byte_count = 0;
|
||||
struct evbuffer * out = msgs->outMessages;
|
||||
void * bytes = tr_cpCreatePieceBitfield( &msgs->torrent->completion, &byte_count );
|
||||
|
||||
assert( tr_torrentHasMetadata( msgs->torrent ) );
|
||||
|
||||
bytes = tr_cpCreatePieceBitfield( &msgs->torrent->completion, &byte_count );
|
||||
evbuffer_add_uint32( out, sizeof( uint8_t ) + byte_count );
|
||||
evbuffer_add_uint8 ( out, BT_BITFIELD );
|
||||
evbuffer_add ( out, bytes, byte_count );
|
||||
|
|
|
@ -652,12 +652,16 @@ addField( const tr_torrent * const tor,
|
|||
else if( tr_streq( key, keylen, "peersSendingToUs" ) )
|
||||
tr_bencDictAddInt( d, key, st->peersSendingToUs );
|
||||
else if( tr_streq( key, keylen, "pieces" ) ) {
|
||||
if (tr_torrentHasMetadata( tor ) ) {
|
||||
size_t byte_count = 0;
|
||||
void * bytes = tr_cpCreatePieceBitfield( &tor->completion, &byte_count );
|
||||
char * str = tr_base64_encode( bytes, byte_count, NULL );
|
||||
tr_bencDictAddStr( d, key, str!=NULL ? str : "" );
|
||||
tr_free( str );
|
||||
tr_free( bytes );
|
||||
} else {
|
||||
tr_bencDictAddStr( d, key, "" );
|
||||
}
|
||||
}
|
||||
else if( tr_streq( key, keylen, "pieceCount" ) )
|
||||
tr_bencDictAddInt( d, key, inf->pieceCount );
|
||||
|
|
Loading…
Reference in a new issue