]> source.dussan.org Git - poi.git/commitdiff
fix issue in IOUtils.toByteArrayWithMaxLength
authorPJ Fanning <fanningpj@apache.org>
Fri, 11 Mar 2022 21:24:51 +0000 (21:24 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 11 Mar 2022 21:24:51 +0000 (21:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898861 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java
poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
poi/src/main/java/org/apache/poi/util/IOUtils.java

index 718e0368070d0de943601ad87fcbc7fa58d9b5f8..4eca4905263dac0f2da8bbc6e3ca66ac6d3d8c60 100644 (file)
@@ -92,13 +92,11 @@ public class XWPFChart extends XDDFChart {
 
     public Long getChecksum() {
         if (this.checksum == null) {
-            byte[] data;
             try (InputStream is = getPackagePart().getInputStream()) {
-                data = IOUtils.toByteArrayWithMaxLength(is, XWPFPictureData.getMaxImageSize());
+                this.checksum = IOUtils.calculateChecksum(is);
             } catch (IOException e) {
                 throw new POIXMLException(e);
             }
-            this.checksum = IOUtils.calculateChecksum(data);
         }
         return this.checksum;
     }
index a4a84021ed13d5901739caadb206e6f3b8faf762..4e4ad700ca8eb5303a03db00d926d32fa5df1db9 100644 (file)
@@ -163,13 +163,11 @@ public class XWPFPictureData extends POIXMLDocumentPart {
 
     public Long getChecksum() {
         if (this.checksum == null) {
-            byte[] data;
             try (InputStream is = getPackagePart().getInputStream()) {
-                data = IOUtils.toByteArrayWithMaxLength(is, getMaxImageSize());
+                this.checksum = IOUtils.calculateChecksum(is);
             } catch (IOException e) {
                 throw new POIXMLException(e);
             }
-            this.checksum = IOUtils.calculateChecksum(data);
         }
         return this.checksum;
     }
index 37ad46846f6ffa7d0ee45db390e8176e550b4ce8..f0dbc1aa99ebf595ae2bc60f32fd848d062abe94 100644 (file)
@@ -202,7 +202,7 @@ public final class IOUtils {
         }
 
         final int derivedLen = Math.min(length, derivedMaxLength);
-        final int bufferLen = isLengthKnown ? derivedLen : 4096;
+        final int bufferLen = isLengthKnown ? derivedLen : Math.min(4096, derivedLen);
         try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(bufferLen)) {
             byte[] buffer = new byte[4096];
             int totalBytes = 0, readBytes;