From 7a5d04eed4ee5a746e779471789ea7b91430edeb Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Thu, 1 Dec 2005 13:56:43 +0000 Subject: [PATCH] Fix an unsafe loop. --- btpd/upload.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/btpd/upload.c b/btpd/upload.c index 94d3eb4..42de2ac 100644 --- a/btpd/upload.c +++ b/btpd/upload.c @@ -42,10 +42,12 @@ ul_on_lost_peer(struct peer *p) void ul_on_lost_torrent(struct torrent *tp) { - struct peer *p; - BTPDQ_FOREACH(p, &tp->peers, p_entry) { + struct peer *p = BTPDQ_FIRST(&m_peerq); + while (p != NULL) { + struct peer *next = BTPDQ_NEXT(p, p_entry); BTPDQ_REMOVE(&m_peerq, p, ul_entry); m_npeers--; + p = next; } choke_do(); }