From 372c25024c6315a328d787e8b3571f14e4680ef7 Mon Sep 17 00:00:00 2001 From: Karlatemp Date: Fri, 18 Nov 2022 20:41:53 +0800 Subject: [PATCH] [core] Fix temporary buffer acquiring; Fix #2309 --- mirai-core/src/commonMain/kotlin/utils/crypto/TEA.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/utils/crypto/TEA.kt b/mirai-core/src/commonMain/kotlin/utils/crypto/TEA.kt index 310e116a6..4c1d8d02f 100644 --- a/mirai-core/src/commonMain/kotlin/utils/crypto/TEA.kt +++ b/mirai-core/src/commonMain/kotlin/utils/crypto/TEA.kt @@ -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() }