Paper/Spigot-Server-Patches/0318-Cleanup-allocated-favicon-ByteBuf.patch

44 lines
2.0 KiB
Diff
Raw Normal View History

From bb2607ef12aebead5c261dc647acbc233def762a Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
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