fix loop bounds
authorChristian Grothoff <christian@grothoff.org>
Tue, 25 Oct 2011 13:24:36 +0000 (13:24 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 25 Oct 2011 13:24:36 +0000 (13:24 +0000)
src/dht/gnunet-service-dht_neighbours.c

index 637c9ecc72d7b8e520008a45426360922bc71cc6..9362d28c5cbb7c03c683f6a7491156d72df7824d 100644 (file)
@@ -1065,7 +1065,7 @@ select_peer (const GNUNET_HashCode *key,
   /* select "random" peer */
   /* count number of peers that are available and not filtered */
   count = 0;
-  for (bc = closest_bucket; bc < MAX_BUCKETS; bc++)
+  for (bc = 0; bc < closest_bucket; bc++)
   {
     pos = k_buckets[bc].head;
     while ((pos != NULL) && (count < bucket_size))
@@ -1100,7 +1100,7 @@ select_peer (const GNUNET_HashCode *key,
   /* Now actually choose a peer */
   selected = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, count);
   count = 0;
-  for (bc = closest_bucket; bc < MAX_BUCKETS; bc++)
+  for (bc = 0; bc < closest_bucket; bc++)
   {
     pos = k_buckets[bc].head;
     while ((pos != NULL) && (count < bucket_size))