ref: b1fc00d5dc0e89432c58367477b6d9d63b6b0be9
parent: 23c093fc38326d98a58dd482ed6afa4b02d2a004
author: Werner Lemberg <[email protected]>
date: Fri Nov 21 07:06:40 EST 2014
* src/pcf/pcfread.c (pcf_get_metrics): Sanitize invalid metrics.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2014-11-21 Werner Lemberg <[email protected]>
+ * src/pcf/pcfread.c (pcf_get_metrics): Sanitize invalid metrics.
+
+2014-11-21 Werner Lemberg <[email protected]>
+
[ftlcdfil] Obey flow direction.
* src/base/ftlcdfil.c (_ft_lcd_filter_fir, _ft_lcd_filter_legacy):
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -649,24 +649,40 @@
return FT_THROW( Out_Of_Memory );
metrics = face->metrics;
- for ( i = 0; i < nmetrics; i++ )
+ for ( i = 0; i < nmetrics; i++, metrics++ )
{
- error = pcf_get_metric( stream, format, metrics + i );
+ error = pcf_get_metric( stream, format, metrics );
- metrics[i].bits = 0;
+ metrics->bits = 0;
FT_TRACE5(( " idx %d: width=%d, "
"lsb=%d, rsb=%d, ascent=%d, descent=%d, swidth=%d\n",
i,
- ( metrics + i )->characterWidth,
- ( metrics + i )->leftSideBearing,
- ( metrics + i )->rightSideBearing,
- ( metrics + i )->ascent,
- ( metrics + i )->descent,
- ( metrics + i )->attributes ));
+ metrics->characterWidth,
+ metrics->leftSideBearing,
+ metrics->rightSideBearing,
+ metrics->ascent,
+ metrics->descent,
+ metrics->attributes ));
if ( error )
break;
+
+ /* sanity checks -- those values are used in `PCF_Glyph_Load' to */
+ /* compute a glyph's bitmap dimensions, thus setting them to zero in */
+ /* case of an error disables this particular glyph only */
+ if ( metrics->rightSideBearing < metrics->leftSideBearing ||
+ metrics->ascent + metrics->descent < 0 )
+ {
+ metrics->characterWidth = 0;
+ metrics->leftSideBearing = 0;
+ metrics->rightSideBearing = 0;
+ metrics->ascent = 0;
+ metrics->descent = 0;
+
+ FT_TRACE0(( "pcf_get_metrics:"
+ " invalid metrics for glyph %d\n", i ));
+ }
}
if ( error )