[core] Fix temporary buffer acquiring; Fix #2309

This commit is contained in:
Karlatemp 2022-11-18 20:41:53 +08:00
parent b38687a3ea
commit 372c25024c
No known key found for this signature in database
GPG Key ID: BA173CA2B9956C59

View File

@ -46,7 +46,7 @@ internal object TEA {
length: Int = receiver.remaining.toInt() - offset,
consumer: (ByteArray) -> Unit,
) {
ByteArrayPool.useInstance {
ByteArrayPool.useInstance(length) {
receiver.readFully(it, offset, length)
consumer(encrypt(it, key, length = length))
}
@ -68,7 +68,7 @@ internal object TEA {
length: Int = (receiver.remaining - offset).toInt(),
consumer: (ByteArray) -> R,
): R {
return ByteArrayPool.useInstance {
return ByteArrayPool.useInstance(length) {
receiver.readFully(it, offset, length)
consumer(decrypt(it, key, length))
}.also { receiver.close() }