==================================================================== */
package org.apache.poi.hpsf;
+import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
@Internal
-public class Array
-{
+public class Array {
+
+ private static final int MAX_NUMBER_OF_ARRAY_SCALARS = 100_000;
+
static class ArrayDimension {
private long _size;
@SuppressWarnings("unused")
}
}
- static class ArrayHeader
- {
+ static class ArrayHeader {
private ArrayDimension[] _dimensions;
private int _type;
String msg = "Array dimension number "+numDimensionsUnsigned+" is not in [1; 31] range";
throw new IllegalPropertySetDataException(msg);
}
-
+
int numDimensions = (int) numDimensionsUnsigned;
_dimensions = new ArrayDimension[numDimensions];
}
int numberOfScalars = (int) numberOfScalarsLong;
+ IOUtils.safelyAllocateCheck(numberOfScalars, MAX_NUMBER_OF_ARRAY_SCALARS);
+
_values = new TypedPropertyValue[numberOfScalars];
int paddedType = (_header._type == Variant.VT_VARIANT) ? 0 : _header._type;
for ( int i = 0; i < numberOfScalars; i++ ) {