aboutsummaryrefslogtreecommitdiffstats
path: root/poi-scratchpad/src
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-10-21 10:08:35 +0000
committerPJ Fanning <fanningpj@apache.org>2021-10-21 10:08:35 +0000
commitfa00e7d472eafd6354e77b43c3668cd205f857a3 (patch)
tree5a9ebfcc81398466cf0e8bc4bf2bc56dba5effef /poi-scratchpad/src
parent63e7f91d1b10a8cd93b56da264d8bfb0a732988e (diff)
downloadpoi-fa00e7d472eafd6354e77b43c3668cd205f857a3.tar.gz
poi-fa00e7d472eafd6354e77b43c3668cd205f857a3.zip
[bug-65639] increase max size of HSLF font data and try to cache the FontHeader instance
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894438 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-scratchpad/src')
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java
index b9acb2e3bf..b27cdb4b53 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/FontEmbeddedData.java
@@ -31,8 +31,8 @@ import org.apache.poi.util.LittleEndian;
@SuppressWarnings("WeakerAccess")
public class FontEmbeddedData extends RecordAtom implements FontFacet {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 1_000_000;
+ //arbitrarily selected; may need to increase (increased due to https://bz.apache.org/bugzilla/show_bug.cgi?id=65639)
+ private static final int MAX_RECORD_LENGTH = 5_000_000;
/**
* Record header.
@@ -45,6 +45,11 @@ public class FontEmbeddedData extends RecordAtom implements FontFacet {
private byte[] _data;
/**
+ * A cached FontHeader so that we don't keep creating new FontHeader instances
+ */
+ private FontHeader fontHeader;
+
+ /**
* Constructs a brand new font embedded record.
*/
/* package */ FontEmbeddedData() {
@@ -87,14 +92,18 @@ public class FontEmbeddedData extends RecordAtom implements FontFacet {
}
public void setFontData(byte[] fontData) {
+ fontHeader = null;
_data = fontData.clone();
LittleEndian.putInt(_header, 4, _data.length);
}
public FontHeader getFontHeader() {
- FontHeader h = new FontHeader();
- h.init(_data, 0, _data.length);
- return h;
+ if (fontHeader == null) {
+ FontHeader h = new FontHeader();
+ h.init(_data, 0, _data.length);
+ fontHeader = h;
+ }
+ return fontHeader;
}
@Override