Don't fail when reading an empty script.

This commit is contained in:
Eric Mader 2002-09-06 22:45:23 +00:00
parent 441e7d0292
commit c880e814a5
2 changed files with 26 additions and 11 deletions

View File

@ -130,7 +130,7 @@
if ( s->LangSysCount == 0 && s->DefaultLangSys.FeatureCount == 0 )
{
error = TTO_Err_Invalid_SubTable;
error = TTO_Err_Empty_Script;
goto Fail2;
}
@ -205,7 +205,7 @@
FT_Error error;
FT_Memory memory = stream->memory;
FT_UShort n, m, count;
FT_UShort n, script_count;
FT_ULong cur_offset, new_offset, base_offset;
TTO_ScriptRecord* sr;
@ -216,39 +216,53 @@
if ( ACCESS_Frame( 2L ) )
return error;
count = sl->ScriptCount = GET_UShort();
script_count = GET_UShort();
FORGET_Frame();
sl->ScriptRecord = NULL;
if ( ALLOC_ARRAY( sl->ScriptRecord, count, TTO_ScriptRecord ) )
if ( ALLOC_ARRAY( sl->ScriptRecord, script_count, TTO_ScriptRecord ) )
return error;
sr = sl->ScriptRecord;
for ( n = 0; n < count; n++ )
sl->ScriptCount= 0;
for ( n = 0; n < script_count; n++ )
{
if ( ACCESS_Frame( 6L ) )
goto Fail;
sr[n].ScriptTag = GET_ULong();
sr[sl->ScriptCount].ScriptTag = GET_ULong();
new_offset = GET_UShort() + base_offset;
FORGET_Frame();
cur_offset = FILE_Pos();
if ( FILE_Seek( new_offset ) ||
( error = Load_Script( &sr[n].Script, stream ) ) != TT_Err_Ok )
if ( FILE_Seek( new_offset ) )
goto Fail;
error = Load_Script( &sr[sl->ScriptCount].Script, stream );
if ( error == TT_Err_Ok )
sl->ScriptCount += 1;
else if ( error != TTO_Err_Empty_Script )
goto Fail;
(void)FILE_Seek( cur_offset );
}
if ( sl->ScriptCount == 0 )
{
error = TTO_Err_Invalid_SubTable;
goto Fail;
}
return TT_Err_Ok;
Fail:
for ( m = 0; m < n; m++ )
Free_Script( &sr[m].Script, memory );
for ( n = 0; n < sl->ScriptCount; n++ )
Free_Script( &sr[n].Script, memory );
FREE( sl->ScriptRecord );
return error;

View File

@ -38,6 +38,7 @@ extern "C" {
#define TTO_Err_Not_Covered 0x1002
#define TTO_Err_Too_Many_Nested_Contexts 0x1003
#define TTO_Err_No_MM_Interpreter 0x1004
#define TTO_Err_Empty_Script 0x1005
/* Script list related structures */