mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-06 10:45:37 +01:00
a9ca533e3f
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by 2LStudios and as with ANY update, please do your own testing
Waterfall Changes:
9dd430a
Updated Upstream (BungeeCord) (#667)
128 lines
5.9 KiB
Diff
128 lines
5.9 KiB
Diff
From fb2700e20203d8aeb36b8f64b688df0b264cb9dc Mon Sep 17 00:00:00 2001
|
|
From: linsaftw <linsaftw@users.noreply.github.com>
|
|
Date: Sat, 20 Mar 2021 12:36:25 -0300
|
|
Subject: [PATCH] Fix ByteBuf memory leaks
|
|
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
index 3e3e42a2..ccab6800 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
|
@@ -275,9 +275,15 @@ public class ServerConnector extends PacketHandler
|
|
} else
|
|
{
|
|
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
- DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
|
- user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) );
|
|
- brand.release();
|
|
+
|
|
+ try
|
|
+ {
|
|
+ DefinedPacket.writeString( bungee.getName() + " (" + bungee.getVersion() + ")", brand );
|
|
+ user.unsafe().sendPacket( new PluginMessage( user.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand", brand, handshakeHandler.isServerForge() ) );
|
|
+ } finally
|
|
+ {
|
|
+ brand.release();
|
|
+ }
|
|
}
|
|
|
|
user.setDimension( login.getDimension() );
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
index 9e180c30..40c016d6 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
@@ -287,15 +287,24 @@ public class DownstreamBridge extends PacketHandler
|
|
if ( pluginMessage.getTag().equals( con.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand" ) )
|
|
{
|
|
ByteBuf brand = Unpooled.wrappedBuffer( pluginMessage.getData() );
|
|
- String serverBrand = DefinedPacket.readString( brand );
|
|
- brand.release();
|
|
|
|
- Preconditions.checkState( !serverBrand.contains( bungee.getName() ), "Cannot connect proxy to itself!" );
|
|
+ try {
|
|
+ String serverBrand;
|
|
|
|
- brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
- DefinedPacket.writeString( bungee.getName() + " <- " + serverBrand, brand ); // Waterfall
|
|
- pluginMessage.setData( brand );
|
|
- brand.release();
|
|
+ try {
|
|
+ serverBrand = DefinedPacket.readString( brand );
|
|
+ } finally {
|
|
+ brand.release();
|
|
+ }
|
|
+
|
|
+ Preconditions.checkState( !serverBrand.contains( bungee.getName() ), "Cannot connect proxy to itself!" );
|
|
+
|
|
+ brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
+ DefinedPacket.writeString( bungee.getName() + " <- " + serverBrand, brand ); // Waterfall
|
|
+ pluginMessage.setData( brand );
|
|
+ } finally {
|
|
+ brand.release();
|
|
+ }
|
|
// changes in the packet are ignored so we need to send it manually
|
|
con.unsafe().sendPacket( pluginMessage );
|
|
throw CancelSendSignal.INSTANCE;
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
index 09df5a93..67ef2cb4 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
@@ -142,11 +142,15 @@ public abstract class EntityMap
|
|
if ( readId == oldId || readId == newId )
|
|
{
|
|
ByteBuf data = packet.copy();
|
|
- packet.readerIndex( offset );
|
|
- packet.writerIndex( offset );
|
|
- DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet );
|
|
- packet.writeBytes( data );
|
|
- data.release();
|
|
+
|
|
+ try {
|
|
+ packet.readerIndex( offset );
|
|
+ packet.writerIndex( offset );
|
|
+ DefinedPacket.writeVarInt( readId == oldId ? newId : oldId, packet );
|
|
+ packet.writeBytes( data );
|
|
+ } finally {
|
|
+ data.release();
|
|
+ }
|
|
}
|
|
}
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java
|
|
index cefa0206..8d4439ab 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java
|
|
@@ -38,16 +38,22 @@ public class ForgeUtils
|
|
{
|
|
Map<String, String> modTags = new HashMap<>();
|
|
ByteBuf payload = Unpooled.wrappedBuffer( pluginMessage.getData() );
|
|
- byte discriminator = payload.readByte();
|
|
- if ( discriminator == 2 ) // ModList
|
|
- {
|
|
- ByteBuf buffer = payload.slice();
|
|
- int modCount = DefinedPacket.readVarInt( buffer, 2 );
|
|
- for ( int i = 0; i < modCount; i++ )
|
|
+
|
|
+ try {
|
|
+ byte discriminator = payload.readByte();
|
|
+ if ( discriminator == 2 ) // ModList
|
|
{
|
|
- modTags.put( DefinedPacket.readString( buffer ), DefinedPacket.readString( buffer ) );
|
|
+ ByteBuf buffer = payload.slice();
|
|
+ int modCount = DefinedPacket.readVarInt( buffer, 2 );
|
|
+ for ( int i = 0; i < modCount; i++ )
|
|
+ {
|
|
+ modTags.put( DefinedPacket.readString( buffer ), DefinedPacket.readString( buffer ) );
|
|
+ }
|
|
}
|
|
+ } finally {
|
|
+ payload.release();
|
|
}
|
|
+
|
|
return modTags;
|
|
}
|
|
|
|
--
|
|
2.32.0.windows.1
|
|
|