From 55f0835fff8bf8be6a58813b6c9faec97ec5597c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 18 Oct 2019 14:46:59 +0200 Subject: Fix out of bounds accesses in Bitset --- test/bitset_test.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'test/bitset_test.c') diff --git a/test/bitset_test.c b/test/bitset_test.c index dbb7bd7..4514e79 100644 --- a/test/bitset_test.c +++ b/test/bitset_test.c @@ -74,10 +74,9 @@ main(int argc, char** argv) } zix_bitset_clear(b, t, N_BITS); - for (size_t i = 0; i <= N_BITS; i += 2) { - if (i < N_BITS) { - zix_bitset_set(b, t, i); - } + for (size_t i = 0; i < N_BITS; i += 2) { + zix_bitset_set(b, t, i); + const size_t count = zix_bitset_count_up_to(b, t, i + 1); const size_t result = MIN(N_BITS / 2, i / 2 + 1); if (count != result) { -- cgit v1.2.1