From 617691251e5d69465388edc1375be68db5071293 Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Wed, 6 Jul 2005 19:10:59 +0000 Subject: [PATCH] It wasn't safe to modify the list from within the loop. Fixed it. --- btpd/policy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/btpd/policy.c b/btpd/policy.c index 44f0d12..6050351 100644 --- a/btpd/policy.c +++ b/btpd/policy.c @@ -303,11 +303,13 @@ cm_on_lost_peer(struct peer *peer) if ((peer->flags & (PF_I_WANT|PF_P_CHOKE)) == PF_I_WANT) cm_on_undownload(peer); - for (piece = BTPDQ_FIRST(&tp->getlst); piece; - piece = BTPDQ_NEXT(piece, entry)) { + piece = BTPDQ_FIRST(&tp->getlst); + while (piece != NULL) { + struct piece *next = BTPDQ_NEXT(piece, entry); if (has_bit(peer->piece_field, piece->index) && tp->piece_count[piece->index] == 0) cm_on_peerless_piece(tp, piece); + piece = next; } }