From efd6cb08125414bf11d3278d77ebc98e2efcdaf5 Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Wed, 7 Oct 2015 21:39:43 +0100 Subject: [PATCH] Ensure the buffer for plugin messages is freed. --- nms-patches/PlayerConnection.patch | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index 26d4212d76..a1f3b5280b 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -1425,7 +1425,15 @@ ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator(); -@@ -921,13 +1884,16 @@ +@@ -905,6 +1868,7 @@ + ItemStack itemstack; + ItemStack itemstack1; + ++ try { // CraftBukkit + if ("MC|BEdit".equals(packetplayincustompayload.a())) { + packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.b())); + +@@ -921,13 +1885,16 @@ itemstack1 = this.player.inventory.getItemInHand(); if (itemstack1 != null) { if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { @@ -1442,7 +1450,7 @@ return; } finally { packetdataserializer.release(); -@@ -950,16 +1916,21 @@ +@@ -950,16 +1917,21 @@ itemstack1 = this.player.inventory.getItemInHand(); if (itemstack1 != null) { if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.WRITABLE_BOOK) { @@ -1464,7 +1472,7 @@ return; } finally { packetdataserializer.release(); -@@ -976,11 +1947,12 @@ +@@ -976,11 +1948,12 @@ } } catch (Exception exception2) { PlayerConnection.c.error("Couldn\'t select trade", exception2); @@ -1478,7 +1486,7 @@ packetdataserializer = packetplayincustompayload.b(); try { -@@ -1016,6 +1988,7 @@ +@@ -1016,6 +1989,7 @@ } } catch (Exception exception3) { PlayerConnection.c.error("Couldn\'t set command block", exception3); @@ -1486,7 +1494,7 @@ } finally { packetdataserializer.release(); } -@@ -1041,6 +2014,7 @@ +@@ -1041,6 +2015,7 @@ } } catch (Exception exception4) { PlayerConnection.c.error("Couldn\'t set beacon", exception4); @@ -1494,7 +1502,7 @@ } } } else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) { -@@ -1056,7 +2030,28 @@ +@@ -1056,7 +2031,35 @@ containeranvil.a(""); } } @@ -1515,6 +1523,13 @@ + server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.a(), data); + } + // CraftBukkit end ++ // CraftBukkit start ++ } finally { ++ if (packetplayincustompayload.b().refCnt() > 0) { ++ packetplayincustompayload.b().release(); ++ } ++ } ++ // CraftBukkit end + } + // CraftBukkit start - Add "isDisconnected" method