Changeset 11210


Ignore:
Timestamp:
Sep 14, 2010, 6:07:42 PM (11 years ago)
Author:
Longinus00
Message:

(trunk) check for duplicate ids when removing trackers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpcimpl.c

    r11209 r11210  
    897897    int i;
    898898    int n;
     899    int t = 0;
     900    int dup = -1;
    899901    int * tids;
    900     int t = 0;
    901902    tr_benc * val;
    902903    tr_tracker_info * trackers;
     
    920921    }
    921922
    922     /* sort trackerIds because tr_removeElementFromArray changes indices as it removes */
     923    /* sort trackerIds and remove from largest to smallest so there is no need to recacluate array indicies */
    923924    qsort( tids, t, sizeof(int), compareInt );
    924 
    925     /* remove from largest trackerId to smallest */
    926925    while( t-- )
    927926    {
     927        /* check for duplicates */
     928        if( tids[t] == dup )
     929            continue;
    928930        tr_removeElementFromArray( trackers, tids[t], sizeof( tr_tracker_info ), n-- );
     931        dup = tids[t];
    929932        changed = TRUE;
    930933    }
Note: See TracChangeset for help on using the changeset viewer.