[sfnt] Additional checks for 'colr' table presence. * sfnt/ttcolr.c (tt_face_get_colr_glyph_paint, tt_face_get_colorline_stops, tt_face_get_paint): Additional checks for whether colr table is present. Prevents crashes when these methods are called on non-COLR fonts.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/ChangeLog b/ChangeLog
index eee3100..a8b5cda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-01-14 Dominik Röttsches <drott@chromium.org>
+
+ [sfnt] Additional checks for 'colr' table presence.
+
+ * sfnt/ttcolr.c (tt_face_get_colr_glyph_paint,
+ tt_face_get_colorline_stops, tt_face_get_paint): Additional checks
+ for whether colr table is present. Prevents crashes when these
+ methods are called on non-COLR fonts.
+
2021-01-13 Dominik Röttsches <drott@chromium.org>
Add config option to test for 'COLR' v1 support in headers.
diff --git a/src/sfnt/ttcolr.c b/src/sfnt/ttcolr.c
index a39773d..9de391d 100644
--- a/src/sfnt/ttcolr.c
+++ b/src/sfnt/ttcolr.c
@@ -665,6 +665,9 @@
FT_Byte* p;
+ if ( !colr )
+ return 0;
+
if ( colr->version < 1 || !colr->num_base_glyphs_v1 ||
!colr->base_glyphs_v1 )
return 0;
@@ -755,6 +758,9 @@
FT_Byte* p;
+ if ( !colr )
+ return 0;
+
if ( iterator->current_color_stop >= iterator->num_color_stops )
return 0;
@@ -793,6 +799,9 @@
FT_Byte* p;
+ if ( !colr )
+ return 0;
+
if ( opaque_paint.p < (FT_Byte*)colr->table ||
opaque_paint.p >= ( (FT_Byte*)colr->table + colr->table_size ) )
return 0;