2021-12-30 03:02:28 +01:00
|
|
|
From 02edb203875d8fc08fc20f529b7a401a8b797755 Mon Sep 17 00:00:00 2001
|
2021-10-01 03:27:34 +02:00
|
|
|
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/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
2021-10-11 06:29:24 +02:00
|
|
|
index a70405dc..33b72eb0 100644
|
2021-10-01 03:27:34 +02:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
2021-10-11 06:29:24 +02:00
|
|
|
@@ -150,11 +150,15 @@ public abstract class EntityMap
|
2021-10-01 03:27:34 +02:00
|
|
|
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
|
2021-10-11 06:29:24 +02:00
|
|
|
index cefa0206..8d4439ab 100644
|
2021-10-01 03:27:34 +02:00
|
|
|
--- 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2021-12-30 03:02:28 +01:00
|
|
|
2.32.0
|
2021-10-01 03:27:34 +02:00
|
|
|
|