Fix issues with decoding and Java fallback native

This commit is contained in:
Andrew Steinborn
2019-10-19 23:56:44 -04:00
parent a16684564b
commit 6ff5cac4d3
4 changed files with 36 additions and 20 deletions

View File

@@ -18,10 +18,11 @@ public class MinecraftCipherDecoder extends ByteToMessageDecoder {
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
ByteBuf compatible = MoreByteBufUtils.ensureCompatible(ctx.alloc(), cipher, in);
ByteBuf compatible = MoreByteBufUtils.ensureCompatible(ctx.alloc(), cipher, in).slice();
try {
cipher.process(compatible);
out.add(compatible);
in.skipBytes(in.readableBytes());
} catch (Exception e) {
compatible.release(); // compatible will never be used if we throw an exception
throw e;