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

Fix writeFully argument validation in Builder.kt #120

Closed
wants to merge 1 commit into from

Conversation

BenWoodworth
Copy link

override fun writeFully(src: IntArray, offset: Int, length: Int) {
    require(length >= 0) { "length shouldn't be negative: $length" }
    require(offset + length < src.lastIndex) { "offset ($offset) + length ($length) >= src.lastIndex (${src.lastIndex})" }
    // ...

The second require statement was incorrect in the writeFully methods. (e.g. for src=[1], offset=0, length=1, you'll get require(0 + 1 < 0))

I also added validation to make sure offset is non-negative, like in other places in the repo.

@BenWoodworth
Copy link
Author

I'm not sure why it's failing CI checks (compiles fine and passes tests on my machine), but let me know if any changes need to be made

@e5l e5l closed this May 26, 2021
@e5l e5l reopened this May 26, 2021
@qwwdfsad
Copy link
Member

Closing as "won't fix", please see https://github.com/Kotlin/kotlinx-io#obsolete-warning

@qwwdfsad qwwdfsad closed this Nov 29, 2022
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