Fix ByteBuf leak in Js5ResponseDecoder

Signed-off-by: Graham <gpe@openrs2.org>
pull/132/head
Graham 3 years ago
parent e1404a1f7f
commit 6a800c0759
  1. 12
      protocol/src/main/kotlin/org/openrs2/protocol/js5/Js5ResponseDecoder.kt

@ -78,6 +78,7 @@ public class Js5ResponseDecoder : ByteToMessageDecoder() {
data.writeBytes(input, blockLen)
if (!last && input.readUnsignedByte().toInt() != 0xFF) {
reset()
throw DecoderException("Invalid block trailer")
}
}
@ -90,8 +91,19 @@ public class Js5ResponseDecoder : ByteToMessageDecoder() {
}
}
override fun channelInactive(ctx: ChannelHandlerContext) {
super.channelInactive(ctx)
reset()
}
override fun handlerRemoved0(ctx: ChannelHandlerContext?) {
reset()
}
private fun reset() {
data.release()
data = Unpooled.EMPTY_BUFFER
state = State.READ_HEADER
}
}

Loading…
Cancel
Save