mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
(trunk) check for duplicate ids when removing trackers
This commit is contained in:
parent
ac53f4792f
commit
09df34e4c4
1 changed files with 7 additions and 4 deletions
|
@ -896,8 +896,9 @@ removeTrackers( tr_torrent * tor, tr_benc * ids )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int n;
|
int n;
|
||||||
int * tids;
|
|
||||||
int t = 0;
|
int t = 0;
|
||||||
|
int dup = -1;
|
||||||
|
int * tids;
|
||||||
tr_benc * val;
|
tr_benc * val;
|
||||||
tr_tracker_info * trackers;
|
tr_tracker_info * trackers;
|
||||||
tr_bool changed = FALSE;
|
tr_bool changed = FALSE;
|
||||||
|
@ -919,13 +920,15 @@ removeTrackers( tr_torrent * tor, tr_benc * ids )
|
||||||
tids[t++] = pos;
|
tids[t++] = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sort trackerIds because tr_removeElementFromArray changes indices as it removes */
|
/* sort trackerIds and remove from largest to smallest so there is no need to recacluate array indicies */
|
||||||
qsort( tids, t, sizeof(int), compareInt );
|
qsort( tids, t, sizeof(int), compareInt );
|
||||||
|
|
||||||
/* remove from largest trackerId to smallest */
|
|
||||||
while( t-- )
|
while( t-- )
|
||||||
{
|
{
|
||||||
|
/* check for duplicates */
|
||||||
|
if( tids[t] == dup )
|
||||||
|
continue;
|
||||||
tr_removeElementFromArray( trackers, tids[t], sizeof( tr_tracker_info ), n-- );
|
tr_removeElementFromArray( trackers, tids[t], sizeof( tr_tracker_info ), n-- );
|
||||||
|
dup = tids[t];
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue