summaryrefslogtreecommitdiffstats
path: root/src/cff/cf2intrp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cff/cf2intrp.c')
-rw-r--r--src/cff/cf2intrp.c73
1 files changed, 53 insertions, 20 deletions
diff --git a/src/cff/cf2intrp.c b/src/cff/cf2intrp.c
index 5610917..537e060 100644
--- a/src/cff/cf2intrp.c
+++ b/src/cff/cf2intrp.c
@@ -4,7 +4,7 @@
/* */
/* Adobe's CFF Interpreter (body). */
/* */
-/* Copyright 2007-2013 Adobe Systems Incorporated. */
+/* Copyright 2007-2014 Adobe Systems Incorporated. */
/* */
/* This software, and all works of authorship, whether in source or */
/* object code form as indicated by the copyright notice(s) included */
@@ -43,6 +43,7 @@
#include "cf2font.h"
#include "cf2stack.h"
#include "cf2hints.h"
+#include "cf2intrp.h"
#include "cf2error.h"
@@ -593,8 +594,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid horizontal hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -614,8 +618,11 @@
/* never add hints after the mask is computed */
if ( cf2_hintmask_isValid( &hintMask ) )
+ {
FT_TRACE4(( "cf2_interpT2CharString:"
" invalid vertical hint mask\n" ));
+ break;
+ }
cf2_doStems( font,
opStack,
@@ -754,16 +761,19 @@
/* push our current CFF charstring region on subrStack */
charstring = (CF2_Buffer)
- cf2_arrstack_getPointer( &subrStack,
- charstringIndex + 1 );
+ cf2_arrstack_getPointer(
+ &subrStack,
+ (size_t)charstringIndex + 1 );
/* set up the new CFF region and pointer */
- subrIndex = cf2_stack_popInt( opStack );
+ subrIndex = (CF2_UInt)cf2_stack_popInt( opStack );
switch ( op1 )
{
case cf2_cmdCALLGSUBR:
- FT_TRACE4(( "(%d)\n", subrIndex + decoder->globals_bias ));
+ FT_TRACE4(( " (idx %d, entering level %d)\n",
+ subrIndex + (CF2_UInt)decoder->globals_bias,
+ charstringIndex + 1 ));
if ( cf2_initGlobalRegionBuffer( decoder,
subrIndex,
@@ -776,7 +786,9 @@
default:
/* cf2_cmdCALLSUBR */
- FT_TRACE4(( "(%d)\n", subrIndex + decoder->locals_bias ));
+ FT_TRACE4(( " (idx %d, entering level %d)\n",
+ subrIndex + (CF2_UInt)decoder->locals_bias,
+ charstringIndex + 1 ));
if ( cf2_initLocalRegionBuffer( decoder,
subrIndex,
@@ -792,7 +804,7 @@
continue; /* do not clear the stack */
case cf2_cmdRETURN:
- FT_TRACE4(( " return\n" ));
+ FT_TRACE4(( " return (leaving level %d)\n", charstringIndex ));
if ( charstringIndex < 1 )
{
@@ -803,8 +815,9 @@
/* restore position in previous charstring */
charstring = (CF2_Buffer)
- cf2_arrstack_getPointer( &subrStack,
- --charstringIndex );
+ cf2_arrstack_getPointer(
+ &subrStack,
+ (CF2_UInt)--charstringIndex );
continue; /* do not clear the stack */
case cf2_cmdESC:
@@ -1082,8 +1095,8 @@
/* must be either 4 or 5 -- */
/* this is a (deprecated) implied `seac' operator */
- CF2_UInt achar;
- CF2_UInt bchar;
+ CF2_Int achar;
+ CF2_Int bchar;
CF2_BufferRec component;
CF2_Fixed dummyWidth; /* ignore component width */
FT_Error error2;
@@ -1141,15 +1154,16 @@
/* `cf2_hintmask_read' (which also traces the mask bytes) */
FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" ));
- /* if there are arguments on the stack, there this is an */
- /* implied cf2_cmdVSTEMHM */
- if ( cf2_stack_count( opStack ) != 0 )
+ /* never add hints after the mask is computed */
+ if ( cf2_stack_count( opStack ) > 1 &&
+ cf2_hintmask_isValid( &hintMask ) )
{
- /* never add hints after the mask is computed */
- if ( cf2_hintmask_isValid( &hintMask ) )
- FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" ));
+ break;
}
+ /* if there are arguments on the stack, there this is an */
+ /* implied cf2_cmdVSTEMHM */
cf2_doStems( font,
opStack,
&vStemHintArray,
@@ -1284,10 +1298,16 @@
case cf2_cmdVVCURVETO:
{
- CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt count, count1 = cf2_stack_count( opStack );
CF2_UInt index = 0;
+ /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */
+ /* we enforce it by clearing the second bit */
+ /* (and sorting the stack indexing to suit) */
+ count = count1 & ~2;
+ index += count1 - count;
+
FT_TRACE4(( " vvcurveto\n" ));
while ( index < count )
@@ -1323,10 +1343,16 @@
case cf2_cmdHHCURVETO:
{
- CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt count, count1 = cf2_stack_count( opStack );
CF2_UInt index = 0;
+ /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */
+ /* we enforce it by clearing the second bit */
+ /* (and sorting the stack indexing to suit) */
+ count = count1 & ~2;
+ index += count1 - count;
+
FT_TRACE4(( " hhcurveto\n" ));
while ( index < count )
@@ -1363,12 +1389,19 @@
case cf2_cmdVHCURVETO:
case cf2_cmdHVCURVETO:
{
- CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt count, count1 = cf2_stack_count( opStack );
CF2_UInt index = 0;
FT_Bool alternate = op1 == cf2_cmdHVCURVETO;
+ /* if `cf2_stack_count' isn't of the form 8n, 8n+1, */
+ /* 8n+4, or 8n+5, we enforce it by clearing the */
+ /* second bit */
+ /* (and sorting the stack indexing to suit) */
+ count = count1 & ~2;
+ index += count1 - count;
+
FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" ));
while ( index < count )