From 420c96f74ef6598bc96c8774d5397522803027e8 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 25 Mar 2023 20:09:30 +0000 Subject: [PATCH] don't share the skip bytes buffer git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1908716 13f79535-47bb-0310-9956-ffa450edef68 --- poi/src/main/java/org/apache/poi/util/IOUtils.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/poi/src/main/java/org/apache/poi/util/IOUtils.java b/poi/src/main/java/org/apache/poi/util/IOUtils.java index a69f1b052f..6dd510fe39 100644 --- a/poi/src/main/java/org/apache/poi/util/IOUtils.java +++ b/poi/src/main/java/org/apache/poi/util/IOUtils.java @@ -124,6 +124,12 @@ public final class IOUtils { } } + private static void checkByteSizeLimit(long length) { + if(BYTE_ARRAY_MAX_OVERRIDE != -1 && length > BYTE_ARRAY_MAX_OVERRIDE) { + throwRFE(length, BYTE_ARRAY_MAX_OVERRIDE); + } + } + /** * Peeks at the first N bytes of the stream. Returns those bytes, but * with the stream unaffected. Requires a stream that supports mark/reset, @@ -539,7 +545,7 @@ public final class IOUtils { public static byte[] safelyAllocate(long length, int maxLength) { safelyAllocateCheck(length, maxLength); - checkByteSizeLimit((int)length); + checkByteSizeLimit(length); return new byte[(int)length]; } @@ -570,8 +576,6 @@ public final class IOUtils { } - - /** * Simple utility function to check that you haven't hit EOF * when reading a byte. -- 2.39.5