Archiviert
13
0

Properly cleanup ByteBuf in WirePacket (#487)

* Properly cleanup ByteBuf

* Release store ByteBuf also
Dieser Commit ist enthalten in:
dextonanderson 2018-07-09 11:07:43 -05:00 committet von Dan Mulloy
Ursprung 1d11908af1
Commit aed2285bcb
2 geänderte Dateien mit 264 neuen und 256 gelöschten Zeilen

Datei anzeigen

@ -158,7 +158,7 @@ public class WirePacket {
* bytes from that packet
*
* @param packet Existing packet
* @return The ByteBuf
* @return the byte array
*/
public static byte[] bytesFromPacket(PacketContainer packet) {
checkNotNull(packet, "packet cannot be null!");
@ -177,6 +177,8 @@ public class WirePacket {
byte[] bytes = getBytes(buffer);
buffer.release();
// Rewrite them to the packet to avoid issues with certain packets
if (packet.getType() == PacketType.Play.Server.CUSTOM_PAYLOAD
|| packet.getType() == PacketType.Play.Client.CUSTOM_PAYLOAD) {
@ -195,6 +197,8 @@ public class WirePacket {
return ret;
}
store.release();
return bytes;
}
@ -220,7 +224,11 @@ public class WirePacket {
throw new RuntimeException("Failed to serialize packet contents.", ex);
}
return new WirePacket(id, getBytes(buffer));
byte[] bytes = getBytes(buffer);
buffer.release();
return new WirePacket(id, bytes);
}
public static void writeVarInt(ByteBuf output, int i) {