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;
}
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;
}
}
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;