Make readVarLongInfo account for stream end
This commit is contained in:
parent
ac9a882f12
commit
ffa7f0361f
@ -4,7 +4,7 @@ kotlin.code.style=official
|
|||||||
specifyKotlinAsDependency=false
|
specifyKotlinAsDependency=false
|
||||||
|
|
||||||
projectGroup=ru.dbotthepony.kommons
|
projectGroup=ru.dbotthepony.kommons
|
||||||
projectVersion=2.1.3
|
projectVersion=2.1.5
|
||||||
|
|
||||||
guavaDepVersion=33.0.0
|
guavaDepVersion=33.0.0
|
||||||
gsonDepVersion=2.8.9
|
gsonDepVersion=2.8.9
|
||||||
|
@ -85,6 +85,9 @@ private fun readVarLongInfo(supplier: IntSupplier): VarLongReadResult {
|
|||||||
var read = supplier.asInt
|
var read = supplier.asInt
|
||||||
var i = 1
|
var i = 1
|
||||||
|
|
||||||
|
if (read == -1)
|
||||||
|
throw EOFException()
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
result = (result shl 7) or (read.toLong() and 0x7F)
|
result = (result shl 7) or (read.toLong() and 0x7F)
|
||||||
|
|
||||||
@ -92,6 +95,10 @@ private fun readVarLongInfo(supplier: IntSupplier): VarLongReadResult {
|
|||||||
break
|
break
|
||||||
|
|
||||||
read = supplier.asInt
|
read = supplier.asInt
|
||||||
|
|
||||||
|
if (read == -1)
|
||||||
|
throw EOFException("Reached end of stream before finished reading variable length integer (read totally $i bytes)")
|
||||||
|
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user