aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/cid/cidload.c
diff options
context:
space:
mode:
Diffstat (limited to 'freetype/src/cid/cidload.c')
-rw-r--r--freetype/src/cid/cidload.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/freetype/src/cid/cidload.c b/freetype/src/cid/cidload.c
index 44646a764..b39d6c3a6 100644
--- a/freetype/src/cid/cidload.c
+++ b/freetype/src/cid/cidload.c
@@ -4,7 +4,7 @@
/* */
/* CID-keyed Type1 font loader (body). */
/* */
-/* Copyright 1996-2006, 2009, 2011-2013 by */
+/* Copyright 1996-2006, 2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -150,8 +150,6 @@
cid_parse_font_matrix( CID_Face face,
CID_Parser* parser )
{
- FT_Matrix* matrix;
- FT_Vector* offset;
CID_FaceDict dict;
FT_Face root = (FT_Face)&face->root;
FT_Fixed temp[6];
@@ -160,14 +158,28 @@
if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
{
+ FT_Matrix* matrix;
+ FT_Vector* offset;
+ FT_Int result;
+
+
dict = face->cid.font_dicts + parser->num_dict;
matrix = &dict->font_matrix;
offset = &dict->font_offset;
- (void)cid_parser_to_fixed_array( parser, 6, temp, 3 );
+ result = cid_parser_to_fixed_array( parser, 6, temp, 3 );
+
+ if ( result < 6 )
+ return FT_THROW( Invalid_File_Format );
temp_scale = FT_ABS( temp[3] );
+ if ( temp_scale == 0 )
+ {
+ FT_ERROR(( "cid_parse_font_matrix: invalid font matrix\n" ));
+ return FT_THROW( Invalid_File_Format );
+ }
+
/* Set Units per EM based on FontMatrix values. We set the value to */
/* 1000 / temp_scale, because temp_scale was already multiplied by */
/* 1000 (in t1_tofixed, from psobjs.c). */
@@ -182,7 +194,7 @@
temp[2] = FT_DivFix( temp[2], temp_scale );
temp[4] = FT_DivFix( temp[4], temp_scale );
temp[5] = FT_DivFix( temp[5], temp_scale );
- temp[3] = 0x10000L;
+ temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
}
matrix->xx = temp[0];
@@ -195,8 +207,7 @@
offset->y = temp[5] >> 16;
}
- return FT_Err_Ok; /* this is a callback function; */
- /* we must return an error code */
+ return FT_Err_Ok;
}