Fix return value to only contain TTO_Err_Not_Covered if *no* lookups
Sat Jul 26 22:12:46 2003 Owen Taylor <otaylor@redhat.com> * pango/opentype/ftxgsub.c (Do_String_Lookup, TT_GSUB_Apply_String): Fix return value to only contain TTO_Err_Not_Covered if *no* lookups matched. Fix memory leaks on error in Apply_String().
This commit is contained in:
parent
e10ea2afd9
commit
03a0fe09c7
|
@ -4303,7 +4303,7 @@
|
||||||
TTO_GSUB_String* in,
|
TTO_GSUB_String* in,
|
||||||
TTO_GSUB_String* out )
|
TTO_GSUB_String* out )
|
||||||
{
|
{
|
||||||
FT_Error error = TTO_Err_Not_Covered;
|
FT_Error error, retError = TTO_Err_Not_Covered;
|
||||||
|
|
||||||
FT_UShort* properties = gsub->LookupList.Properties;
|
FT_UShort* properties = gsub->LookupList.Properties;
|
||||||
FT_UShort* p_in = in->properties;
|
FT_UShort* p_in = in->properties;
|
||||||
|
@ -4319,9 +4319,14 @@
|
||||||
/* 0xFFFF indicates that we don't have a context length yet */
|
/* 0xFFFF indicates that we don't have a context length yet */
|
||||||
error = Do_Glyph_Lookup( gsub, lookup_index, in, out,
|
error = Do_Glyph_Lookup( gsub, lookup_index, in, out,
|
||||||
0xFFFF, nesting_level );
|
0xFFFF, nesting_level );
|
||||||
if ( error && error != TTO_Err_Not_Covered )
|
if ( error )
|
||||||
|
{
|
||||||
|
if ( error != TTO_Err_Not_Covered )
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
retError = error;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
error = TTO_Err_Not_Covered;
|
error = TTO_Err_Not_Covered;
|
||||||
|
|
||||||
|
@ -4330,7 +4335,7 @@
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return retError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4473,7 +4478,7 @@
|
||||||
TTO_GSUB_String* in,
|
TTO_GSUB_String* in,
|
||||||
TTO_GSUB_String* out )
|
TTO_GSUB_String* out )
|
||||||
{
|
{
|
||||||
FT_Error error = TTO_Err_Not_Covered;
|
FT_Error error, retError = TTO_Err_Not_Covered;
|
||||||
FT_Memory memory = in->memory;
|
FT_Memory memory = in->memory;
|
||||||
FT_UShort j;
|
FT_UShort j;
|
||||||
|
|
||||||
|
@ -4497,27 +4502,11 @@
|
||||||
tmp1.allocated = in->length;
|
tmp1.allocated = in->length;
|
||||||
tmp1.pos = in->pos;
|
tmp1.pos = in->pos;
|
||||||
tmp1.max_ligID = 1;
|
tmp1.max_ligID = 1;
|
||||||
|
tmp1.string = NULL;
|
||||||
if ( ALLOC_ARRAY( tmp1.string, tmp1.length, FT_UShort ) )
|
tmp1.properties = NULL;
|
||||||
return error;
|
tmp1.components = NULL;
|
||||||
MEM_Copy( tmp1.string, in->string, in->length * sizeof ( FT_UShort ) );
|
tmp1.ligIDs = NULL;
|
||||||
|
tmp1.logClusters = NULL;
|
||||||
/* make sure that we always have a `properties', `components', and
|
|
||||||
`ligIDs' array in the string object */
|
|
||||||
|
|
||||||
if ( ALLOC_ARRAY( tmp1.components, tmp1.length, FT_UShort ) )
|
|
||||||
return error;
|
|
||||||
if ( ALLOC_ARRAY( tmp1.ligIDs, tmp1.length, FT_UShort ) )
|
|
||||||
return error;
|
|
||||||
if ( ALLOC_ARRAY( tmp1.properties, tmp1.length, FT_UShort ) )
|
|
||||||
return error;
|
|
||||||
if ( in->properties )
|
|
||||||
MEM_Copy( tmp1.properties, in->properties,
|
|
||||||
in->length * sizeof( FT_UShort ) );
|
|
||||||
if ( ALLOC_ARRAY( tmp1.logClusters, tmp1.length, FT_Int ) )
|
|
||||||
return error;
|
|
||||||
MEM_Copy( tmp1.logClusters, in->logClusters,
|
|
||||||
in->length * sizeof( FT_Int ) );
|
|
||||||
|
|
||||||
tmp2.memory = memory;
|
tmp2.memory = memory;
|
||||||
tmp2.allocated = 0;
|
tmp2.allocated = 0;
|
||||||
|
@ -4531,12 +4520,39 @@
|
||||||
ptmp1 = &tmp1;
|
ptmp1 = &tmp1;
|
||||||
ptmp2 = &tmp2;
|
ptmp2 = &tmp2;
|
||||||
|
|
||||||
|
if ( ALLOC_ARRAY( tmp1.string, tmp1.length, FT_UShort ) )
|
||||||
|
return error;
|
||||||
|
MEM_Copy( tmp1.string, in->string, in->length * sizeof ( FT_UShort ) );
|
||||||
|
|
||||||
|
/* make sure that we always have a `properties', `components', and
|
||||||
|
`ligIDs' array in the string object */
|
||||||
|
|
||||||
|
if ( ALLOC_ARRAY( tmp1.components, tmp1.length, FT_UShort ) )
|
||||||
|
goto End;
|
||||||
|
if ( ALLOC_ARRAY( tmp1.ligIDs, tmp1.length, FT_UShort ) )
|
||||||
|
goto End;
|
||||||
|
if ( ALLOC_ARRAY( tmp1.properties, tmp1.length, FT_UShort ) )
|
||||||
|
goto End;
|
||||||
|
if ( in->properties )
|
||||||
|
MEM_Copy( tmp1.properties, in->properties,
|
||||||
|
in->length * sizeof( FT_UShort ) );
|
||||||
|
if ( ALLOC_ARRAY( tmp1.logClusters, tmp1.length, FT_Int ) )
|
||||||
|
goto End;
|
||||||
|
MEM_Copy( tmp1.logClusters, in->logClusters,
|
||||||
|
in->length * sizeof( FT_Int ) );
|
||||||
|
|
||||||
for ( j = 0; j < gsub->LookupList.LookupCount; j++ )
|
for ( j = 0; j < gsub->LookupList.LookupCount; j++ )
|
||||||
if ( properties[j] )
|
if ( properties[j] )
|
||||||
{
|
{
|
||||||
error = Do_String_Lookup( gsub, j, ptmp1, ptmp2 );
|
error = Do_String_Lookup( gsub, j, ptmp1, ptmp2 );
|
||||||
if ( error && error != TTO_Err_Not_Covered )
|
if ( error )
|
||||||
return error;
|
{
|
||||||
|
if ( error != TTO_Err_Not_Covered )
|
||||||
|
goto End;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
retError = error;
|
||||||
|
|
||||||
|
|
||||||
/* flipping `in' and `out', preparing the next loop */
|
/* flipping `in' and `out', preparing the next loop */
|
||||||
|
|
||||||
|
@ -4550,6 +4566,25 @@
|
||||||
ptmp1 = t;
|
ptmp1 = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
End:
|
||||||
|
FREE( ptmp2->string );
|
||||||
|
FREE( ptmp2->properties );
|
||||||
|
FREE( ptmp2->components );
|
||||||
|
FREE( ptmp2->ligIDs );
|
||||||
|
FREE( ptmp2->logClusters );
|
||||||
|
|
||||||
|
if ( error && error != TTO_Err_Not_Covered )
|
||||||
|
{
|
||||||
|
FREE( ptmp1->string );
|
||||||
|
FREE( ptmp1->components );
|
||||||
|
FREE( ptmp1->ligIDs );
|
||||||
|
FREE( ptmp1->properties );
|
||||||
|
FREE( ptmp1->logClusters );
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
out->length = ptmp1->length;
|
out->length = ptmp1->length;
|
||||||
out->pos = 0;
|
out->pos = 0;
|
||||||
out->allocated = ptmp1->allocated;
|
out->allocated = ptmp1->allocated;
|
||||||
|
@ -4566,13 +4601,8 @@
|
||||||
out->properties = NULL;
|
out->properties = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREE( ptmp2->string );
|
return retError;
|
||||||
FREE( ptmp2->properties );
|
}
|
||||||
FREE( ptmp2->components );
|
|
||||||
FREE( ptmp2->ligIDs );
|
|
||||||
FREE( ptmp2->logClusters );
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue