[truetype/GX] Use more robust conditions.

* src/truetype/ttgxvar.c (ft_var_readpacked{points,deltas}): Rewrite
conditions to avoid undefined behavior.
cmap32
Alexei Podtelezhnikov 5 months ago
parent 5e116bb0dc
commit 7c75b8a7bd
  1. 10
      src/truetype/ttgxvar.c

@ -187,7 +187,7 @@
if ( runcnt & GX_PT_POINTS_ARE_WORDS )
{
if ( p + 2 * cnt > stream->limit )
if ( 2 * cnt > (FT_UInt)( stream->limit - p ) )
goto Fail;
for ( j = 0; j < cnt; j++ )
@ -198,7 +198,7 @@
}
else
{
if ( p + cnt > stream->limit )
if ( cnt > (FT_UInt)( stream->limit - p ) )
goto Fail;
for ( j = 0; j < cnt; j++ )
@ -274,9 +274,7 @@
while ( i < delta_cnt )
{
if ( p >= stream->limit )
{
goto Fail;
}
runcnt = FT_NEXT_BYTE( p );
cnt = runcnt & GX_DT_DELTA_RUN_COUNT_MASK;
@ -293,7 +291,7 @@
}
else if ( runcnt & GX_DT_DELTAS_ARE_WORDS )
{
if ( p + 2 * cnt > stream->limit )
if ( 2 * cnt > (FT_UInt)( stream->limit - p ) )
goto Fail;
for ( j = 0; j < cnt; j++ )
@ -301,7 +299,7 @@
}
else
{
if ( p + cnt > stream->limit )
if ( cnt > (FT_UInt)( stream->limit - p ) )
goto Fail;
for ( j = 0; j < cnt; j++ )

Loading…
Cancel
Save