kotlinx-io icon indicating copy to clipboard operation
kotlinx-io copied to clipboard

Fix writeFully argument validation in Builder.kt

Open BenWoodworth opened this issue 4 years ago • 1 comments

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 avatar Feb 06 '21 06:02 BenWoodworth

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

BenWoodworth avatar Feb 08 '21 04:02 BenWoodworth

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

qwwdfsad avatar Nov 29 '22 15:11 qwwdfsad