From aedf16726899525fda4e86cadfe37b6fb179953e Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 3 Jul 2018 19:19:47 +0100 Subject: [PATCH] Cleanup allocated favicon ByteBuf (fixes #1191) Cleanups a bytebuffer which was allocated during the encoding of the favicon to be sent to the client. --- ...18-Cleanup-allocated-favicon-ByteBuf.patch | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Spigot-Server-Patches/0318-Cleanup-allocated-favicon-ByteBuf.patch diff --git a/Spigot-Server-Patches/0318-Cleanup-allocated-favicon-ByteBuf.patch b/Spigot-Server-Patches/0318-Cleanup-allocated-favicon-ByteBuf.patch new file mode 100644 index 000000000..e57cc05d3 --- /dev/null +++ b/Spigot-Server-Patches/0318-Cleanup-allocated-favicon-ByteBuf.patch @@ -0,0 +1,43 @@ +From bb2607ef12aebead5c261dc647acbc233def762a Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Tue, 3 Jul 2018 19:14:38 +0100 +Subject: [PATCH] Cleanup allocated favicon ByteBuf + +Cleanups a bytebuffer which was allocated during the encoding of the +favicon to be sent to the client. + +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index f82e22b23..0399a48e1 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -724,6 +724,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs + + if (file.isFile()) { + ByteBuf bytebuf = Unpooled.buffer(); ++ ByteBuf bytebuf1 = null; // Paper - cleanup favicon bytebuf + + try { + BufferedImage bufferedimage = ImageIO.read(file); +@@ -731,13 +732,18 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs + Validate.validState(bufferedimage.getWidth() == 64, "Must be 64 pixels wide", new Object[0]); + Validate.validState(bufferedimage.getHeight() == 64, "Must be 64 pixels high", new Object[0]); + ImageIO.write(bufferedimage, "PNG", new ByteBufOutputStream(bytebuf)); +- ByteBuf bytebuf1 = Base64.encode(bytebuf); ++ /*ByteBuf */ bytebuf1 = Base64.encode(bytebuf); // Paper - cleanup favicon bytebuf + + serverping.setFavicon("data:image/png;base64," + bytebuf1.toString(StandardCharsets.UTF_8)); + } catch (Exception exception) { + MinecraftServer.LOGGER.error("Couldn\'t load server icon", exception); + } finally { + bytebuf.release(); ++ // Paper start - cleanup favicon bytebuf ++ if (bytebuf1 != null) { ++ bytebuf1.release(); ++ } ++ // Paper end - cleanup favicon bytebuf + } + } + +-- +2.17.1 +