Skip to content

[Histogram] Fix off-by-one boundary bug#143

Merged
thinkingfish merged 1 commit intopelikan-io:mainfrom
andrijast-db:off-by-one-fix
Jan 12, 2026
Merged

[Histogram] Fix off-by-one boundary bug#143
thinkingfish merged 1 commit intopelikan-io:mainfrom
andrijast-db:off-by-one-fix

Conversation

@andrijast-db
Copy link
Contributor

Fixes issue #142

Problem

Function value_to_index is not working correctly which can result to a index out of bounds panic. That's because max variable is set incorrectly (off-by-one). Case for max_value_power == 64 is already correct as u64::MAX == 2^64 - 1.

Solution

Set max variable to be an inclusive boundary (2^n - 1).

Copy link
Member

@thinkingfish thinkingfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching and fixing this bug!

@thinkingfish thinkingfish merged commit cd52375 into pelikan-io:main Jan 12, 2026
15 checks passed
@andrijast-db
Copy link
Contributor Author

Thank you for catching and fixing this bug!

You're welcome!

Would it be possible to cut a patch release that includes this change?

@thinkingfish
Copy link
Member

Published a new release with the fix. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants