A problem was reported to me where freetype, when given a
corrupt font that looks like it has a recursive composite
glyph, overflows it's stack and crashes. (After allocating
a huge amount of memory.)
The attached patch makes two changes in this area:
- When loading composite glyphs, it puts a hard recursion
limit of 5 on the loading, which should be enough for
any real situation. (The TrueType spec doesn't make
clear whether composite glyphs can have composite
glyphs as subglyphs at all.)
- It makes the check for what is a composite glyph
stricter; only glyphs with a contours_count of -1,
not any negative number, are considered composite glyphs.
(-1 is what the TT spec requires, and this will reduce
the chance of random garbage looking like a composite
glyph.)