Ignore:
Timestamp:
Nov 25, 2009, 6:57:54 PM (12 years ago)
Author:
charles
Message:

(trunk libT) #2110: "allow adding torrents with no trackers" -- fix crash in tr_torrentSetAnnounceList() when the new number of trackers is 0. Reported by Rolcol.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r9570 r9572  
    21172117    if( !tr_bencLoadFile( &metainfo, TR_FMT_BENC, tor->info.torrent ) )
    21182118    {
    2119         int       i;
    2120         int       prevTier = -1;
    2121         tr_benc * tier = NULL;
    2122         tr_benc * announceList;
    21232119        tr_info   tmpInfo;
    21242120
     
    21282124
    21292125        /* add the new fields */
    2130         tr_bencDictAddStr( &metainfo, "announce", trackers[0].announce );
    2131         announceList = tr_bencDictAddList( &metainfo, "announce-list", 0 );
    2132         for( i = 0; i < trackerCount; ++i ) {
    2133             if( prevTier != trackers[i].tier ) {
    2134                 prevTier = trackers[i].tier;
    2135                 tier = tr_bencListAddList( announceList, 0 );
     2126        if( trackerCount > 0 )
     2127        {
     2128            tr_bencDictAddStr( &metainfo, "announce", trackers[0].announce );
     2129        }
     2130        if( trackerCount > 1 )
     2131        {
     2132            int i;
     2133            int prevTier = -1;
     2134            tr_benc * tier = NULL;
     2135            tr_benc * announceList = tr_bencDictAddList( &metainfo, "announce-list", 0 );
     2136
     2137            for( i=0; i<trackerCount; ++i ) {
     2138                if( prevTier != trackers[i].tier ) {
     2139                    prevTier = trackers[i].tier;
     2140                    tier = tr_bencListAddList( announceList, 0 );
     2141                }
     2142                tr_bencListAddStr( tier, trackers[i].announce );
    21362143            }
    2137             tr_bencListAddStr( tier, trackers[i].announce );
    21382144        }
    21392145
Note: See TracChangeset for help on using the changeset viewer.