[base] Set ppem-based rendering limits.

This will not eliminate all rendering timeouts. It is still possible to
scribble excessively within the set limits. At least, the memory usage
will be curtained.

* src/base/ftobjs.c (ft_glyphslot_free_bitmap): Revise limits base on
ppem when available.
This commit is contained in:
Alexei Podtelezhnikov
2026-01-07 13:45:09 -05:00
parent b91f75bd02
commit b096dc0f33

View File

@@ -524,12 +524,20 @@
bitmap->rows = (unsigned int)height;
bitmap->pitch = pitch;
if ( pbox.xMin < -0x8000 || pbox.xMax > 0x7FFF ||
pbox.yMin < -0x8000 || pbox.yMax > 0x7FFF )
/* sanity check */
{
FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n",
pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
return 1;
FT_Face face = slot->face;
FT_Pos xlim = face ? 16 * face->size->metrics.x_ppem : 0x8000;
FT_Pos ylim = face ? 16 * face->size->metrics.y_ppem : 0x8000;
if ( pbox.xMin < -xlim || pbox.xMax > xlim ||
pbox.yMin < -ylim || pbox.yMax > ylim )
{
FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n",
pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
return 1;
}
}
return 0;