Skip to content

Commit

Permalink
[core] Fix temporary buffer acquiring; Fix #2309
Browse files Browse the repository at this point in the history
  • Loading branch information
Karlatemp committed Nov 18, 2022
1 parent b38687a commit 372c250
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mirai-core/src/commonMain/kotlin/utils/crypto/TEA.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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() }
Expand Down

0 comments on commit 372c250

Please sign in to comment.