From 542f87b8f7b991e36710c13b7edca0f6b290e39c Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 28 Jun 2019 15:18:53 -0400 Subject: [PATCH] Fix infinite loop re-sizing block state internal ID array. --- .../worldedit/internal/block/BlockStateIdAccess.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java index 9b02fab98..172289c39 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/block/BlockStateIdAccess.java @@ -57,8 +57,12 @@ public final class BlockStateIdAccess { OptionalInt id = getBlockStateId(blockState); if (id.isPresent()) { int i = id.getAsInt(); - while (i >= blockStates.length) { - blockStates = Arrays.copyOf(blockStates, blockStates.length + blockStates.length >> 1); + if (i >= blockStates.length) { + int curLength = blockStates.length; + do { + curLength += curLength >> 1; + } while (i >= curLength); + blockStates = Arrays.copyOf(blockStates, curLength); } BlockState existing = blockStates[i]; checkState(existing == null || existing == blockState,