Skip to content

Commit

Permalink
fix byte array read size
Browse files Browse the repository at this point in the history
  • Loading branch information
itboy87 committed Oct 4, 2024
1 parent 59651a1 commit bd3d33e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ internal class SourceReaderByteArray(bytes: ByteArray) : SourceReader {

override fun read(bytes: ByteArray, offset: Int, length: Int): Int {
var i = offset
var pos = currentPosition
while (exhausted().not() && i < length) {
bytes[i] = source[currentPosition++]
i++
}
return i
val totalRead = currentPosition - pos
return if (totalRead == 0 && exhausted()) {
-1
} else {
totalRead
}
}

override fun readAllBytes(): ByteArray {
Expand Down

0 comments on commit bd3d33e

Please sign in to comment.