From 4de1f1e8c5ab0788b11a640e2d08ee80d0b53771 Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Wed, 1 Mar 2023 18:01:33 +0100 Subject: [PATCH] Fix potential out of bounds and NPE --- .../Acrobot/ChestShop/Containers/AdminInventory.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Containers/AdminInventory.java b/src/main/java/com/Acrobot/ChestShop/Containers/AdminInventory.java index 92bc8f8..c4c00a6 100644 --- a/src/main/java/com/Acrobot/ChestShop/Containers/AdminInventory.java +++ b/src/main/java/com/Acrobot/ChestShop/Containers/AdminInventory.java @@ -48,7 +48,7 @@ public class AdminInventory implements Inventory { @Override public ItemStack getItem(int i) { - if (content.length < i) { + if (content.length > i) { return content[i]; } return null; @@ -156,10 +156,12 @@ public class AdminInventory implements Inventory { public HashMap all(ItemStack itemStack) { HashMap items = new HashMap(); - ItemStack clone = itemStack.clone(); - clone.setAmount(Integer.MAX_VALUE); + if (itemStack != null) { + ItemStack clone = itemStack.clone(); + clone.setAmount(Integer.MAX_VALUE); - items.put(1, clone); + items.put(1, clone); + } return items; }