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

[BUG] BitBuffer .put and .get methods with arrays have inverted condition on for loop #11

Open
henry701 opened this issue Jun 9, 2021 · 0 comments · May be fixed by #12
Open

[BUG] BitBuffer .put and .get methods with arrays have inverted condition on for loop #11

henry701 opened this issue Jun 9, 2021 · 0 comments · May be fixed by #12

Comments

@henry701
Copy link

henry701 commented Jun 9, 2021

As an example, there is the following code on BitBuffer abstract class convenience method for putting boolean arrays:

public BitBuffer put(boolean[] array) {
    put(array, 0, array.length);
    return this;
}

Which int turn invokes method:

public BitBuffer put(boolean[] array, int offset, int limit) {
    for(; offset > limit; ++offset) {
        put(array[offset]);
    }
    return this;
}

However when invoked the method always skip the for, because the condition is inverted: offset (initial 0) is always <= limit when entering the method!

This is repeated on all instances of such methods, just swapping offset > limit for offset < limit should do the trick!

@henry701 henry701 changed the title BitBuffer .put and .get methods with arrays have inverted condition on for loop [BUG] BitBuffer .put and .get methods with arrays have inverted condition on for loop Jun 9, 2021
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 a pull request may close this issue.

1 participant