This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9d819966f1 more allocation changes (#1120)
9d819966f1 is described below

commit 9d819966f18e10fc35a1eff681bcaa7e0fd8060a
Author: PJ Fanning <[email protected]>
AuthorDate: Fri Jun 5 01:54:46 2026 +0100

    more allocation changes (#1120)
---
 .../src/main/java/org/apache/poi/hwpf/HWPFDocument.java     |  2 +-
 .../src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java |  3 ++-
 .../src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java  |  3 ++-
 .../org/apache/poi/hwpf/converter/AbstractWordUtils.java    |  2 +-
 .../org/apache/poi/hwpf/model/CHPFormattedDiskPage.java     |  3 ++-
 .../java/org/apache/poi/hwpf/model/ComplexFileTable.java    |  3 ++-
 .../java/org/apache/poi/hwpf/model/DocumentProperties.java  |  3 ++-
 .../src/main/java/org/apache/poi/hwpf/model/Ffn.java        |  3 ++-
 .../org/apache/poi/hwpf/model/FileInformationBlock.java     |  3 ++-
 .../src/main/java/org/apache/poi/hwpf/model/ListLevel.java  | 13 +++++++++++--
 .../java/org/apache/poi/hwpf/model/NilPICFAndBinData.java   |  6 +++---
 .../java/org/apache/poi/hwpf/model/OldTextPieceTable.java   |  3 ++-
 .../org/apache/poi/hwpf/model/PICFAndOfficeArtData.java     |  3 ++-
 .../src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java  |  3 ++-
 .../src/main/java/org/apache/poi/hwpf/model/PlfLfo.java     |  4 ++--
 .../main/java/org/apache/poi/hwpf/model/SectionTable.java   |  3 ++-
 .../main/java/org/apache/poi/hwpf/model/TextPieceTable.java |  5 +++--
 .../src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java  |  6 ++++--
 .../src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java   |  2 +-
 .../java/org/apache/poi/hwpf/sprm/TableSprmCompressor.java  |  3 ++-
 20 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
index 67fc4b4414..a9281cb09d 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
@@ -702,7 +702,7 @@ public final class HWPFDocument extends HWPFDocumentCore {
 
         // preserve space for the FileInformationBlock because we will be 
writing
         // it after we write everything else.
-        byte[] placeHolder = IOUtils.safelyAllocate(fibSize, 
MAX_RECORD_LENGTH);
+        byte[] placeHolder = IOUtils.safelyAllocate(fibSize, 
MAX_RECORD_LENGTH, "HWPFDocument.setMaxRecordLength()");
         wordDocumentStream.write(placeHolder);
         int mainOffset = wordDocumentStream.size();
         int tableOffset = 0;
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java
index af2991b368..431856c9ce 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java
@@ -441,7 +441,8 @@ public abstract class HWPFDocumentCore extends POIDocument {
         ChunkedCipherInputStream cis = 
(ChunkedCipherInputStream)dec.getDataStream(dis, streamSize, 0);
         byte[] plain = {};
         if (encryptionOffset > 0) {
-            plain = IOUtils.safelyAllocate(encryptionOffset, 
MAX_RECORD_LENGTH);
+            plain = IOUtils.safelyAllocate(encryptionOffset, MAX_RECORD_LENGTH,
+                    "HWPFDocumentCore.setMaxRecordLength()");
             cis.readPlain(plain, 0, encryptionOffset);
         }
         return new SequenceInputStream(new ByteArrayInputStream(plain), cis);
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java
index 85a17202bf..c5a624144b 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFOldDocument.java
@@ -186,7 +186,8 @@ public class HWPFOldDocument extends HWPFDocumentCore {
         tpt = new OldTextPieceTable();
 
         byte[] textData = IOUtils.safelyClone(_mainStream, 
_fib.getFibBase().getFcMin(),
-              _fib.getFibBase().getFcMac()-_fib.getFibBase().getFcMin(), 
MAX_RECORD_LENGTH);
+              _fib.getFibBase().getFcMac()-_fib.getFibBase().getFcMin(),
+                MAX_RECORD_LENGTH, "HWPFOldDocument.setMaxRecordLength()");
 
         int numChars = textData.length;
         if (DoubleByteUtil.DOUBLE_BYTE_CHARSETS.contains(guessedCharset)) {
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordUtils.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordUtils.java
index 74eb7ff3d3..ed8445be85 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordUtils.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/AbstractWordUtils.java
@@ -251,7 +251,7 @@ public class AbstractWordUtils {
                 bulletBuffer.append( element );
             }
 
-            // ensure this buffer does not grow to much, this should avoid 
cases where
+            // ensure this buffer does not grow too much, this should avoid 
cases where
             // this can "explode", i.e. small input file consumes huge amounts 
of
             // main memory
             IOUtils.safelyAllocateCheck(bulletBuffer.length(), 
MAX_BULLET_BUFFER_SIZE);
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
index 50948b8869..ab592363ff 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CHPFormattedDiskPage.java
@@ -119,7 +119,8 @@ public final class CHPFormattedDiskPage extends 
FormattedDiskPage {
 
         int size = LittleEndian.getUByte(_fkp, _offset + chpxOffset);
 
-        return IOUtils.safelyClone(_fkp, _offset + chpxOffset + 1, size, 
HWPFDocument.getMaxRecordLength());
+        return IOUtils.safelyClone(_fkp, _offset + chpxOffset + 1, size, 
HWPFDocument.getMaxRecordLength(),
+                "HWPFDocument.setMaxRecordLength()");
     }
 
     protected byte[] toByteArray( CharIndexTranslator translator )
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ComplexFileTable.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ComplexFileTable.java
index 22eaadae52..96ca36ea3b 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ComplexFileTable.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ComplexFileTable.java
@@ -55,7 +55,8 @@ public class ComplexFileTable {
             offset++;
             int size = LittleEndian.getShort(tableStream, offset);
             offset += LittleEndianConsts.SHORT_SIZE;
-            byte[] bs = IOUtils.safelyClone(tableStream, offset, size, 
HWPFDocument.getMaxRecordLength());
+            byte[] bs = IOUtils.safelyClone(tableStream, offset, size, 
HWPFDocument.getMaxRecordLength(),
+                    "HWPFDocument.setMaxRecordLength()");
             offset += size;
 
             SprmBuffer sprmBuffer = new SprmBuffer(bs, false, 0);
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java
index 40ccd73cc5..66a6bd3f0f 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/DocumentProperties.java
@@ -46,7 +46,8 @@ public final class DocumentProperties extends DOPAbstractType 
{
         if ( length != supportedSize )
         {
             this._preserved = IOUtils.safelyClone( tableStream, offset + 
supportedSize,
-                    length - supportedSize, HWPFDocument.getMaxRecordLength());
+                    length - supportedSize, HWPFDocument.getMaxRecordLength(),
+                    "HWPFDocument.setMaxRecordLength()");
         }
         else
         {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java
index 3f925f8626..149d2e9a6c 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/Ffn.java
@@ -143,7 +143,8 @@ public final class Ffn {
     // changed protected to public
     public byte[] toByteArray() {
         int offset = 0;
-        byte[] buf = IOUtils.safelyAllocate(this.getSize(), 
HWPFDocument.getMaxRecordLength());
+        byte[] buf = IOUtils.safelyAllocate(this.getSize(), 
HWPFDocument.getMaxRecordLength(),
+                "HWPFDocument.setMaxRecordLength()");
 
         buf[offset] = (byte) _cbFfnM1;
         offset += LittleEndianConsts.BYTE_SIZE;
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java
index c4886c397b..adcac9b6d2 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java
@@ -122,7 +122,8 @@ public final class FileInformationBlock {
 
             // first short is already read as _nFibNew
             final int fibRgCswNewLength = ( _cswNew - 1 ) * 
LittleEndianConsts.SHORT_SIZE;
-            _fibRgCswNew = IOUtils.safelyClone(mainDocument, offset, 
fibRgCswNewLength, HWPFDocument.getMaxRecordLength());
+            _fibRgCswNew = IOUtils.safelyClone(mainDocument, offset, 
fibRgCswNewLength,
+                    HWPFDocument.getMaxRecordLength(), 
"HWPFDocument.setMaxRecordLength()");
         }
         else
         {
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListLevel.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListLevel.java
index 769cdd7b79..cc0616a14a 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListLevel.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/ListLevel.java
@@ -43,7 +43,16 @@ public final class ListLevel
 {
 
     //arbitrarily selected; may need to increase
-    private static final int MAX_RECORD_LENGTH = 10_485_760;
+    private static final int DEFAULT_MAX_RECORD_LENGTH = 10_485_760;
+    private static int MAX_RECORD_LENGTH = DEFAULT_MAX_RECORD_LENGTH;
+
+    public static void setMaxRecordLength(int length) {
+        MAX_RECORD_LENGTH = length;
+    }
+
+    public static int getMaxRecordLength() {
+        return MAX_RECORD_LENGTH;
+    }
 
     private static final Logger LOG = PoiLogManager.getLogger(ListLevel.class);
 
@@ -285,7 +294,7 @@ public final class ListLevel
 
     public byte[] toByteArray()
     {
-        byte[] buf = IOUtils.safelyAllocate(getSizeInBytes(), 
MAX_RECORD_LENGTH);
+        byte[] buf = IOUtils.safelyAllocate(getSizeInBytes(), 
MAX_RECORD_LENGTH, "ListLevel.setMaxRecordLength()");
         int offset = 0;
 
         _lvlf.setCbGrpprlChpx( (short) _grpprlChpx.length );
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/NilPICFAndBinData.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/NilPICFAndBinData.java
index 90388c3830..888bfb281b 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/NilPICFAndBinData.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/NilPICFAndBinData.java
@@ -20,7 +20,7 @@ import java.util.Arrays;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.poi.logging.PoiLogManager;
-import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianConsts;
 
@@ -49,8 +49,8 @@ public class NilPICFAndBinData {
         }
 
         // make sure these do not cause OOM if passed as invalid or extremely 
large values
-        IOUtils.safelyAllocateCheck(lcb, MAX_SIZE);
-        IOUtils.safelyAllocateCheck(cbHeader, MAX_SIZE);
+        ArrayUtil.strictAllocateCheck(lcb, MAX_SIZE);
+        ArrayUtil.strictAllocateCheck(cbHeader, MAX_SIZE);
 
         // skip the 62 ignored bytes
         int binaryLength = lcb - cbHeader;
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java
index f82fd32eff..fb6a7a45b9 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java
@@ -80,7 +80,8 @@ public class OldTextPieceTable extends TextPieceTable {
             int textSizeBytes = Math.multiplyExact(textSizeChars, multiple);
 
             // Grab the data that makes up the piece
-            byte[] buf = IOUtils.safelyClone(documentStream, start, 
textSizeBytes, getMaxRecordLength());
+            byte[] buf = IOUtils.safelyClone(documentStream, start, 
textSizeBytes,
+                    TextPieceTable.getMaxRecordLength(), 
"TextPieceTable.setMaxRecordLength");
 
             // And now build the piece
             final TextPiece newTextPiece = newTextPiece(nodeStartChars, 
nodeEndChars, buf, pieces[x]);
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
index e994b7f8e6..74670304fb 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PICFAndOfficeArtData.java
@@ -65,7 +65,8 @@ public class PICFAndOfficeArtData {
             short _cchPicName = LittleEndian.getUByte(dataStream, offset);
             offset += 1;
 
-            _stPicName = IOUtils.safelyClone(dataStream, offset, _cchPicName, 
HWPFDocument.getMaxRecordLength());
+            _stPicName = IOUtils.safelyClone(dataStream, offset, _cchPicName, 
HWPFDocument.getMaxRecordLength(),
+                    "HWPFDocument.setMaxRecordLength()");
             offset += _cchPicName;
         }
 
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java
index fc2f85900c..5e1008e2ad 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java
@@ -20,6 +20,7 @@ package org.apache.poi.hwpf.model;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
@@ -58,7 +59,7 @@ public final class PlexOfCps {
         // Figure out the number we hold
         _iMac = (cb - 4) / (4 + cbStruct);
 
-        IOUtils.safelyAllocateCheck(_iMac, MAX_NUMBER_OF_PROPERTIES);
+        ArrayUtil.strictAllocateCheck(_iMac, MAX_NUMBER_OF_PROPERTIES);
 
         _cbStruct = cbStruct;
         _props = new ArrayList<>(_iMac);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java
index a63c0bdeea..ca58949e29 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java
@@ -26,7 +26,7 @@ import java.util.NoSuchElementException;
 import org.apache.logging.log4j.Logger;
 import org.apache.poi.logging.PoiLogManager;
 import org.apache.poi.hwpf.model.types.LFOAbstractType;
-import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.ArrayUtil;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianConsts;
 
@@ -78,7 +78,7 @@ public class PlfLfo {
                             + Integer.MAX_VALUE + " elements" );
         }
 
-        IOUtils.safelyAllocateCheck(lfoMacLong, MAX_NUMBER_OF_LFO);
+        ArrayUtil.strictAllocateCheck(lfoMacLong, MAX_NUMBER_OF_LFO);
 
         this._lfoMac = Math.toIntExact(lfoMacLong);
         _rgLfo = new LFO[_lfoMac];
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/SectionTable.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/SectionTable.java
index efdfeb26cb..db0fc05822 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/SectionTable.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/SectionTable.java
@@ -79,7 +79,8 @@ public class SectionTable {
                 // The first short at the offset is the size of the grpprl.
                 int sepxSize = LittleEndian.getShort(documentStream, 
fileOffset);
                 fileOffset += LittleEndianConsts.SHORT_SIZE;
-                byte[] buf = IOUtils.safelyClone(documentStream, fileOffset, 
sepxSize, HWPFDocument.getMaxRecordLength());
+                byte[] buf = IOUtils.safelyClone(documentStream, fileOffset, 
sepxSize,
+                        HWPFDocument.getMaxRecordLength(), 
"HWPFDocument.setMaxRecordLength()");
                 _sections.add(new SEPX(sed, startAt, endAt, buf));
             }
         }
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java
index aa02c1bf1e..350c2eff02 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java
@@ -115,7 +115,8 @@ public class TextPieceTable implements CharIndexTranslator {
             int textSizeBytes = Math.multiplyExact(textSizeChars, multiple);
 
             // Grab the data that makes up the piece
-            byte[] buf = IOUtils.safelyClone(documentStream, start, 
textSizeBytes, MAX_RECORD_LENGTH);
+            byte[] buf = IOUtils.safelyClone(documentStream, start, 
textSizeBytes, MAX_RECORD_LENGTH,
+                    "TextPieceTable.setMaxRecordLength()");
 
             // And now build the piece
             final TextPiece newTextPiece = newTextPiece(nodeStartChars, 
nodeEndChars, buf,
@@ -428,7 +429,7 @@ public class TextPieceTable implements CharIndexTranslator {
             int mod = (offset % POIFSConstants.SMALLER_BIG_BLOCK_SIZE);
             if (mod != 0) {
                 mod = POIFSConstants.SMALLER_BIG_BLOCK_SIZE - mod;
-                byte[] buf = IOUtils.safelyAllocate(mod, MAX_RECORD_LENGTH);
+                byte[] buf = IOUtils.safelyAllocate(mod, MAX_RECORD_LENGTH, 
"TextPieceTable.setMaxRecordLength()");
                 docStream.write(buf);
             }
 
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java
index 38a0efaa02..c24b03e382 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmBuffer.java
@@ -53,7 +53,8 @@ public final class SprmBuffer implements Duplicatable {
     }
 
     public SprmBuffer(int sprmsStartOffset) {
-        _buf = IOUtils.safelyAllocate(sprmsStartOffset + 4L, 
SprmUtils.MAX_RECORD_LENGTH);
+        _buf = IOUtils.safelyAllocate(sprmsStartOffset + 4L, 
SprmUtils.MAX_RECORD_LENGTH,
+                "SprmUtils.setMaxRecordLength()");
         _offset = sprmsStartOffset;
         _sprmsStartOffset = sprmsStartOffset;
     }
@@ -115,7 +116,8 @@ public final class SprmBuffer implements Duplicatable {
             // commented - buffer shall not contain any additional bytes --
             // sergey
             // byte[] newBuf = new byte[_offset + addition + 6];
-            IOUtils.safelyAllocateCheck(_offset + (long)addition, 
SprmUtils.MAX_RECORD_LENGTH);
+            IOUtils.safelyAllocateCheck(_offset + (long)addition, 
SprmUtils.MAX_RECORD_LENGTH,
+                    "SprmUtils.setMaxRecordLength()");
             _buf = Arrays.copyOf(_buf, _offset + addition);
         }
     }
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java
index 45c1f0d31c..65340cd527 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/SprmUtils.java
@@ -111,7 +111,7 @@ public final class SprmUtils {
     public static byte[] getGrpprl(List<byte[]> sprmList, int size)
     {
         // spit out the final grpprl
-        byte[] grpprl = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH);
+        byte[] grpprl = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH, 
"SprmUtils.setMaxRecordLength()");
         int listSize = sprmList.size() - 1;
         int index = 0;
         for (; listSize >= 0; listSize--)
diff --git 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/TableSprmCompressor.java
 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/TableSprmCompressor.java
index 2cb073afe4..fac112cff6 100644
--- 
a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/TableSprmCompressor.java
+++ 
b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/sprm/TableSprmCompressor.java
@@ -81,7 +81,8 @@ public final class TableSprmCompressor {
               1
                 + (LittleEndianConsts.SHORT_SIZE*((long)itcMac + 1))
                 + (TableCellDescriptor.SIZE*(long)itcMac),
-              SprmUtils.MAX_RECORD_LENGTH);
+              SprmUtils.MAX_RECORD_LENGTH,
+              "SprmUtils.setMaxRecordLength()");
       buf[0] = (byte)itcMac;
 
       short[] dxaCenters = newTAP.getRgdxaCenter();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to