From 64ba0db228d9ec7ab3ad86ceafd3d557e6874555 Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Wed, 27 Mar 2024 00:52:21 -0400 Subject: [PATCH] [F] Fix memory leak --- .../icu/samnyan/aqua/sega/aimedb/AimeDbDecoder.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/icu/samnyan/aqua/sega/aimedb/AimeDbDecoder.kt b/src/main/java/icu/samnyan/aqua/sega/aimedb/AimeDbDecoder.kt index e2bd3355..fa3ccb6e 100644 --- a/src/main/java/icu/samnyan/aqua/sega/aimedb/AimeDbDecoder.kt +++ b/src/main/java/icu/samnyan/aqua/sega/aimedb/AimeDbDecoder.kt @@ -3,7 +3,6 @@ package icu.samnyan.aqua.sega.aimedb import io.netty.buffer.ByteBuf import io.netty.channel.ChannelHandlerContext import io.netty.handler.codec.ByteToMessageDecoder -import org.slf4j.Logger import org.slf4j.LoggerFactory /** @@ -11,7 +10,7 @@ import org.slf4j.LoggerFactory */ class AimeDbDecoder : ByteToMessageDecoder() { companion object { - val logger: Logger = LoggerFactory.getLogger(AimeDbDecoder::class.java) + val logger = LoggerFactory.getLogger(AimeDbDecoder::class.java) } var length = 0 @@ -28,11 +27,14 @@ class AimeDbDecoder : ByteToMessageDecoder() { if (length < 0 || input.readableBytes() < length) return // Create a byte array to store the encrypted data - val result = AimeDbEncryption.decrypt(input.readBytes(length)) + val d = input.readBytes(length) + val result = AimeDbEncryption.decrypt(d) + d.release() - val resultMap: MutableMap = HashMap() - resultMap["type"] = result.getShortLE(0x04).toInt() - resultMap["data"] = result + val resultMap = mapOf( + "type" to result.getShortLE(0x04).toInt(), + "data" to result + ) logger.debug("AimeDB Request Type: " + resultMap["type"])