Trim the length bitset_run_count looks at not to exceed the bits array

This commit is contained in:
Alex Young
2012-06-21 12:05:01 +01:00
parent 80fff4e0e6
commit c054403208

View File

@@ -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);