From c0544032086c5e19d2ca5b1df7f907a58133c178 Mon Sep 17 00:00:00 2001 From: Alex Young Date: Thu, 21 Jun 2012 12:05:01 +0100 Subject: [PATCH] Trim the length bitset_run_count looks at not to exceed the bits array --- src/bitset.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bitset.h b/src/bitset.h index 23f688f..599c367 100644 --- a/src/bitset.h +++ b/src/bitset.h @@ -140,6 +140,9 @@ static inline int bitset_run_count( uint64_t from, uint64_t len) { + /* now fix in case len goes past the end of the memory we have + * control of */ + len = len+from>set->size ? set->size-from : len; INT_FIRST_AND_LAST; return (bit_run_count(set->bits, first, bitlen) * set->resolution) - (from % set->resolution);