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 {
|
||||
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;
|
||||
|
@ -4,38 +4,22 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
import java.util.List;
|
||||
|
||||
public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
read_lens: while (in.isReadable()) {
|
||||
int origReaderIndex = in.readerIndex();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (!in.isReadable()) {
|
||||
in.readerIndex(origReaderIndex);
|
||||
return;
|
||||
}
|
||||
while (in.isReadable()) {
|
||||
int ri = in.readerIndex();
|
||||
int packetLength = ProtocolUtils.readVarInt(in);
|
||||
|
||||
byte read = in.readByte();
|
||||
if (read >= 0) {
|
||||
// Make sure reader index of length buffer is returned to the beginning
|
||||
in.readerIndex(origReaderIndex);
|
||||
int packetLength = ProtocolUtils.readVarInt(in);
|
||||
|
||||
if (in.readableBytes() >= packetLength) {
|
||||
out.add(in.readRetainedSlice(packetLength));
|
||||
continue read_lens;
|
||||
} else {
|
||||
in.readerIndex(origReaderIndex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (in.readableBytes() >= packetLength) {
|
||||
out.add(in.readBytes(packetLength));
|
||||
} else {
|
||||
in.readerIndex(ri);
|
||||
break;
|
||||
}
|
||||
|
||||
throw new CorruptedFrameException("VarInt too big");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren