From 8929168380e5bbfb655a5f1363b74847386004a1 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 12 Jul 2008 07:25:10 +0000 Subject: [PATCH] 2008-07-12 Tatsuhiro Tsujikawa Fixed the bug that causes infinite loop when the number of pieces are fewer than allowed fast set size which is 10 by default. * src/DefaultBtContext.cc --- ChangeLog | 6 ++++++ src/DefaultBtContext.cc | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 949c7c6d..5743cdb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-07-12 Tatsuhiro Tsujikawa + + Fixed the bug that causes infinite loop when the number of pieces are + fewer than allowed fast set size which is 10 by default. + * src/DefaultBtContext.cc + 2008-07-08 Tatsuhiro Tsujikawa Updated the descriptions for -j, -s. Added --bt-seed. diff --git a/src/DefaultBtContext.cc b/src/DefaultBtContext.cc index 9d269b15..8c407e04 100644 --- a/src/DefaultBtContext.cc +++ b/src/DefaultBtContext.cc @@ -422,6 +422,9 @@ void DefaultBtContext::computeFastSet if(!PeerMessageUtil::createcompact(compact, ipaddr, 0)) { return; } + if(numPieces < fastSetSize) { + fastSetSize = numPieces; + } unsigned char tx[24]; memcpy(tx, compact, 4); if((tx[0] & 0x80) == 0 || (tx[0] & 0x40) == 0) {