Ensure the copy is freed if an exception occurs during parsing packets

This commit is contained in:
Thinkofdeath 2015-04-12 01:43:24 +01:00
parent a48c458306
commit d76c8d4f33

View File

@ -23,6 +23,8 @@ public class MinecraftDecoder extends ByteToMessageDecoder
Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT; Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT;
ByteBuf copy = in.copy(); // TODO ByteBuf copy = in.copy(); // TODO
try
{
int packetId = DefinedPacket.readVarInt( in ); int packetId = DefinedPacket.readVarInt( in );
DefinedPacket packet = null; DefinedPacket packet = null;
@ -40,5 +42,13 @@ public class MinecraftDecoder extends ByteToMessageDecoder
} }
out.add( new PacketWrapper( packet, copy ) ); out.add( new PacketWrapper( packet, copy ) );
copy = null;
} finally
{
if ( copy != null )
{
copy.release();
}
}
} }
} }