geforkt von Mirrors/Velocity
Try to diagnose memory leak
Dieser Commit ist enthalten in:
Ursprung
2073d79771
Commit
08df080771
@ -22,7 +22,6 @@ public class MinecraftCipherDecoder extends MessageToMessageDecoder<ByteBuf> {
|
|||||||
try {
|
try {
|
||||||
cipher.process(compatible);
|
cipher.process(compatible);
|
||||||
out.add(compatible);
|
out.add(compatible);
|
||||||
in.skipBytes(in.readableBytes());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
compatible.release(); // compatible will never be used if we throw an exception
|
compatible.release(); // compatible will never be used if we throw an exception
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -4,38 +4,22 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||||
import io.netty.handler.codec.CorruptedFrameException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
read_lens: while (in.isReadable()) {
|
while (in.isReadable()) {
|
||||||
int origReaderIndex = in.readerIndex();
|
int ri = in.readerIndex();
|
||||||
for (int i = 0; i < 3; i++) {
|
int packetLength = ProtocolUtils.readVarInt(in);
|
||||||
if (!in.isReadable()) {
|
|
||||||
in.readerIndex(origReaderIndex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte read = in.readByte();
|
if (in.readableBytes() >= packetLength) {
|
||||||
if (read >= 0) {
|
out.add(in.readBytes(packetLength));
|
||||||
// Make sure reader index of length buffer is returned to the beginning
|
} else {
|
||||||
in.readerIndex(origReaderIndex);
|
in.readerIndex(ri);
|
||||||
int packetLength = ProtocolUtils.readVarInt(in);
|
break;
|
||||||
|
|
||||||
if (in.readableBytes() >= packetLength) {
|
|
||||||
out.add(in.readRetainedSlice(packetLength));
|
|
||||||
continue read_lens;
|
|
||||||
} else {
|
|
||||||
in.readerIndex(origReaderIndex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new CorruptedFrameException("VarInt too big");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren