about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--btpd/peer.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/btpd/peer.c b/btpd/peer.c
index f40e3c1..8aecd0b 100644
--- a/btpd/peer.c
+++ b/btpd/peer.c
@@ -125,6 +125,7 @@ peer_choke(struct peer *p)
 void
 peer_want(struct peer *p, uint32_t index)
 {
+    assert(p->nwant < p->npieces);
     p->nwant++;
     if (p->nwant == 1) {
 	p->flags |= PF_I_WANT;
@@ -135,6 +136,7 @@ peer_want(struct peer *p, uint32_t index)
 void
 peer_unwant(struct peer *p, uint32_t index)
 {
+    assert(p->nwant > 0);
     p->nwant--;
     if (p->nwant == 0) {
 	p->flags &= ~PF_I_WANT;