From ae59137587c0f6eb9884cb9f79c2399894dfea92 Mon Sep 17 00:00:00 2001 From: Raoul Van den Berge Date: Sat, 22 Oct 2016 15:48:00 +0200 Subject: [PATCH] Prevent overflowing of item stacks in lists, #490 --- .../refinedstorage/apiimpl/util/ItemStackList.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/util/ItemStackList.java b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/util/ItemStackList.java index b4cbf5c30..c09b16fd6 100755 --- a/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/util/ItemStackList.java +++ b/src/main/java/com/raoulvdberge/refinedstorage/apiimpl/util/ItemStackList.java @@ -20,8 +20,12 @@ public class ItemStackList implements IItemStackList { public void add(ItemStack stack) { for (ItemStack otherStack : stacks.get(stack.getItem())) { if (API.instance().getComparer().isEqualNoQuantity(otherStack, stack)) { - otherStack.stackSize += stack.stackSize; - + if ((long) otherStack.stackSize + (long) stack.stackSize > Integer.MAX_VALUE) { + otherStack.stackSize = Integer.MAX_VALUE; + } else { + otherStack.stackSize += stack.stackSize; + } + return; } }