Changeset 13504


Ignore:
Timestamp:
Sep 19, 2012, 5:11:19 AM (10 years ago)
Author:
jordan
Message:

(trunk, libt) #4932 'crash on magnet links' -- fixed.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r13113 r13504  
    272272{
    273273    void * ret;
     274    tr_piece_index_t n;
    274275    tr_bitfield pieces;
    275     const tr_piece_index_t n = cp->tor->info.pieceCount;
     276
     277    assert( tr_torrentHasMetadata( cp->tor ) );
     278
     279    n = cp->tor->info.pieceCount;
    276280    tr_bitfieldConstruct( &pieces, n );
    277281
  • trunk/libtransmission/peer-msgs.c

    r13475 r13504  
    19851985sendBitfield( tr_peermsgs * msgs )
    19861986{
     1987    void * bytes;
    19871988    size_t byte_count = 0;
    19881989    struct evbuffer * out = msgs->outMessages;
    1989     void * bytes = tr_cpCreatePieceBitfield( &msgs->torrent->completion, &byte_count );
    1990 
     1990
     1991    assert( tr_torrentHasMetadata( msgs->torrent ) );
     1992
     1993    bytes = tr_cpCreatePieceBitfield( &msgs->torrent->completion, &byte_count );
    19911994    evbuffer_add_uint32( out, sizeof( uint8_t ) + byte_count );
    19921995    evbuffer_add_uint8 ( out, BT_BITFIELD );
  • trunk/libtransmission/rpcimpl.c

    r13359 r13504  
    653653        tr_bencDictAddInt( d, key, st->peersSendingToUs );
    654654    else if( tr_streq( key, keylen, "pieces" ) ) {
    655         size_t byte_count = 0;
    656         void * bytes = tr_cpCreatePieceBitfield( &tor->completion, &byte_count );
    657         char * str = tr_base64_encode( bytes, byte_count, NULL );
    658         tr_bencDictAddStr( d, key, str!=NULL ? str : "" );
    659         tr_free( str );
    660         tr_free( bytes );
     655        if (tr_torrentHasMetadata( tor ) ) {
     656            size_t byte_count = 0;
     657            void * bytes = tr_cpCreatePieceBitfield( &tor->completion, &byte_count );
     658            char * str = tr_base64_encode( bytes, byte_count, NULL );
     659            tr_bencDictAddStr( d, key, str!=NULL ? str : "" );
     660            tr_free( str );
     661            tr_free( bytes );
     662        } else {
     663            tr_bencDictAddStr( d, key, "" );
     664        }
    661665    }
    662666    else if( tr_streq( key, keylen, "pieceCount" ) )
Note: See TracChangeset for help on using the changeset viewer.