mirror of https://github.com/apache/poi.git
[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
This commit is contained in:
parent
63e7f91d1b
commit
fa00e7d472
|
@ -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.
|
||||
|
@ -44,6 +44,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.
|
||||
*/
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue