freetype2/src
Ben Wagner 17545d4bf7 Avoid n^2 scanning for binary data.
When creating a CID parser the location of the 'StartData' or '/sfnts'
tokens needs to be known.  However, the token parser requires that the
entire document be in memory and flattening the entire stream into memory is
to be avoided.

To avoid forcing the entire stream into memory, previously this code would
scan through the stream looking for 'StartData' or '/sfnts' as strings.
However, these strings could have been in a comment or string token, so the
stream would be read into memory up to that point and the parser run to
check that these strings were actually tokens.  This forced a parser restart
from the beginning each time; as a result, data with many 'StartData'
non-tokens would take n^2 time to check.

* src/cid/cidparse.c (cid_parser_new): Change algorithm to make the initial
scan look for the last possible 'StartData' or '/sfnts' string in the
stream.  The stream is read forward instead of backward as a typical normal
CID font will have one 'StartData' toward the beginning of the data and it
it much faster to read the data from beginning to end instead of end to
beginning.  For memory-based fonts the limit is set to the end of the stream
since the stream is already in memory.  Then the parser is run once to look
for 'StartData' or '/sfnts' tokens.  If they are found the parser is re-set
to reflect this new information.

Reported as

  https://issues.chromium.org/issues/40201695
2024-03-08 17:47:43 +01:00
..
autofit Update all copyright notices. 2024-01-27 11:11:22 -05:00
base Update all copyright notices. 2024-01-27 11:11:22 -05:00
bdf Replace `sprintf` with `snprintf`. 2023-05-23 13:18:01 +02:00
bzip2 Update all copyright notices. 2024-01-27 11:11:22 -05:00
cache Update all copyright notices. 2024-01-27 11:11:22 -05:00
cff [cff, truetype] Always set up default variable instance. 2024-02-29 07:06:46 +01:00
cid Avoid n^2 scanning for binary data. 2024-03-08 17:47:43 +01:00
dlg Update all copyright notices. 2024-01-27 11:11:22 -05:00
gxvalid Update all copyright notices. 2024-01-27 11:11:22 -05:00
gzip Update all copyright notices. 2024-01-27 11:11:22 -05:00
lzw Update all copyright notices. 2024-01-27 11:11:22 -05:00
otvalid Update all copyright notices. 2024-01-27 11:11:22 -05:00
pcf * src/pcf/pcfutil.c (BSWAP16): Limit clang support. 2023-10-21 19:08:20 -04:00
pfr Update all copyright notices. 2024-01-27 11:11:22 -05:00
psaux Update all copyright notices. 2024-01-27 11:11:22 -05:00
pshinter Update all copyright notices. 2024-01-27 11:11:22 -05:00
psnames Update all copyright notices. 2024-01-27 11:11:22 -05:00
raster Update all copyright notices. 2024-01-27 11:11:22 -05:00
sdf Update all copyright notices. 2024-01-27 11:11:22 -05:00
sfnt Update all copyright notices. 2024-01-27 11:11:22 -05:00
smooth Update all copyright notices. 2024-01-27 11:11:22 -05:00
svg Update all copyright notices. 2024-01-27 11:11:22 -05:00
tools Update all copyright notices. 2024-01-27 11:11:22 -05:00
truetype [cff, truetype] Always set up default variable instance. 2024-02-29 07:06:46 +01:00
type1 Update all copyright notices. 2024-01-27 11:11:22 -05:00
type42 Update all copyright notices. 2024-01-27 11:11:22 -05:00
winfonts Update all copyright notices. 2024-01-27 11:11:22 -05:00