From fcb4d0948023a360f328fde05b3a9f934ed772c1 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 29 Apr 2022 21:47:45 +0000 Subject: [PATCH] make HPSF limit more configuarble git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1900402 13f79535-47bb-0310-9956-ffa450edef68 --- poi/src/main/java/org/apache/poi/hpsf/Array.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/poi/src/main/java/org/apache/poi/hpsf/Array.java b/poi/src/main/java/org/apache/poi/hpsf/Array.java index eeaf58683f..e366e3cee2 100644 --- a/poi/src/main/java/org/apache/poi/hpsf/Array.java +++ b/poi/src/main/java/org/apache/poi/hpsf/Array.java @@ -22,8 +22,16 @@ import org.apache.poi.util.LittleEndianByteArrayInputStream; @Internal public class Array { + private static final int DEFAULT_MAX_NUMBER_OF_ARRAY_SCALARS = 100_000; + private static int MAX_NUMBER_OF_ARRAY_SCALARS = DEFAULT_MAX_NUMBER_OF_ARRAY_SCALARS; - private static final int MAX_NUMBER_OF_ARRAY_SCALARS = 100_000; + public static int getMaxNumberOfArrayScalars() { + return MAX_NUMBER_OF_ARRAY_SCALARS; + } + + public static void setMaxNumberOfArrayScalars(final int maxNumberOfArrayScalars) { + MAX_NUMBER_OF_ARRAY_SCALARS = maxNumberOfArrayScalars; + } static class ArrayDimension { private long _size; @@ -88,7 +96,7 @@ public class Array { } int numberOfScalars = (int) numberOfScalarsLong; - IOUtils.safelyAllocateCheck(numberOfScalars, MAX_NUMBER_OF_ARRAY_SCALARS); + IOUtils.safelyAllocateCheck(numberOfScalars, getMaxNumberOfArrayScalars()); _values = new TypedPropertyValue[numberOfScalars]; int paddedType = (_header._type == Variant.VT_VARIANT) ? 0 : _header._type;