[SPIGOT-6111] NPE in CraftHumanEntity#openWorkbench & CraftHumanEntity#openEnchanting Created: 27/Aug/20 Updated: 27/Aug/20 Resolved: 27/Aug/20 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | JRoy | Assignee: | md_5 |
Resolution: | Fixed | Votes: | 0 |
Labels: | api | ||
Environment: |
N/A |
Version: | N/A |
Guidelines Read: | Yes |
Description |
In the implementation for openWorkbench and openEnchanting in CraftHumanEntity, the location null check is below the first use of the location object. This will create an NPE if the location parameter is null and the force parameter is false. Player player = Bukkit.getPlayer("md_5"); player.openWorkbench(null, false); //Throws NPE Can be fixed by moving the location null check above force check like so.
if (!force) { Block block = location.getBlock(); if (block.getType() != Material.CRAFTING_TABLE) { return null; } } if (location == null) { location = getLocation(); } // becomes if (location == null) { location = getLocation(); } if (!force) { Block block = location.getBlock(); if (block.getType() != Material.CRAFTING_TABLE) { return null; } }
|
Comments |
Comment by JRoy [ 27/Aug/20 ] |
Ignore title |
Comment by md_5 [ 27/Aug/20 ] |
Regression from when? |