mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 09:19:14 +08:00
[core] Fix temporary buffer acquiring; Fix #2309
This commit is contained in:
parent
b38687a3ea
commit
372c25024c
@ -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() }
|
||||
|
Loading…
Reference in New Issue
Block a user