Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibC: fix bsearch for large arrays #3138

Merged
merged 1 commit into from
Aug 14, 2020

Conversation

tryfinally
Copy link
Contributor

fix bsearch for large arrays due to index computation overflow and mixed signed/unsigned operations.

@awesomekling
Copy link
Collaborator

Please use commit messages to explain what you are changing and why.
From contribution guidelines:

Don't:
Use weasel-words like "refactor" or "fix" to avoid explaining what's being changed.

implement unsigned arithmetics to compute middle without causing overflow.
and without mixed signed/unsigned operations
@awesomekling awesomekling merged commit cdae3f5 into SerenityOS:master Aug 14, 2020
@tryfinally tryfinally deleted the dev-LibC-bsearch branch August 14, 2020 22:19
@BenWiederhake
Copy link
Collaborator

Awesome!

Is there a way to make bsearch a simple wrapper around AK::binary_search? This way, we would avoid having to fix the same bugs in several places, like it happened now with 615ba0f and your commit ^^

@tryfinally
Copy link
Contributor Author

I will into it. I think refactoring both methods to use same core.

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.

None yet

3 participants