aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java4
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java4
-rw-r--r--poi/src/main/java/org/apache/poi/util/IOUtils.java2
3 files changed, 3 insertions, 7 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java
index 718e036807..4eca490526 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java
@@ -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;
}
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
index a4a84021ed..4e4ad700ca 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPictureData.java
@@ -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;
}
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 37ad46846f..f0dbc1aa99 100644
--- a/poi/src/main/java/org/apache/poi/util/IOUtils.java
+++ b/poi/src/main/java/org/apache/poi/util/IOUtils.java
@@ -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;