From f0360d468e0ec4431c458bf5ab83436f12fb9d23 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 18 Mar 2013 20:02:03 +1100 Subject: [PATCH] Prevent NPE in CraftSign This commit prevents the constructor of CraftSign throwing an NPE when it cannot get the sign tile entity. Instead it will fallback to a 4 empty lined sign, and not try to do anything to those lines on .update(). @TheDgtl --- .../0041-Prevent-NPE-in-CraftSign.patch | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 CraftBukkit-Patches/0041-Prevent-NPE-in-CraftSign.patch diff --git a/CraftBukkit-Patches/0041-Prevent-NPE-in-CraftSign.patch b/CraftBukkit-Patches/0041-Prevent-NPE-in-CraftSign.patch new file mode 100644 index 0000000000..0a1303bc32 --- /dev/null +++ b/CraftBukkit-Patches/0041-Prevent-NPE-in-CraftSign.patch @@ -0,0 +1,39 @@ +From 289f93ad3e999628f5d13a5da0fa2939cccbb5dd Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Mon, 18 Mar 2013 20:01:44 +1100 +Subject: [PATCH] Prevent NPE in CraftSign + +This commit prevents the constructor of CraftSign throwing an NPE when it cannot get the sign tile entity. Instead it will fallback to a 4 empty lined sign, and not try to do anything to those lines on .update(). +--- + src/main/java/org/bukkit/craftbukkit/block/CraftSign.java | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +index 8e8a1c5..8b7d226 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java +@@ -14,6 +14,12 @@ public class CraftSign extends CraftBlockState implements Sign { + + CraftWorld world = (CraftWorld) block.getWorld(); + sign = (TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ()); ++ // Spigot start ++ if (sign == null) { ++ lines = new String[4]; ++ return; ++ } ++ // Spigot end + lines = new String[sign.lines.length]; + System.arraycopy(sign.lines, 0, lines, 0, lines.length); + } +@@ -34,7 +40,7 @@ public class CraftSign extends CraftBlockState implements Sign { + public boolean update(boolean force) { + boolean result = super.update(force); + +- if (result) { ++ if (result && sign != null) { // Spigot, add null check + for(int i = 0; i < 4; i++) { + if(lines[i] != null) { + sign.lines[i] = lines[i]; +-- +1.8.1-rc2 +