[cache] Fix error handling.

Manipulate the cache after a face is requested or a size is looked up
successfully. Fixes #1270.

* src/cache/ftcmanag.c (ftc_size_node_init, ftc_size_node_reset,
ftc_face_node_init): Check for errors before accepting a change.
* src/cache/ftcmru.c (FTC_MruList_New): Do nothing if reset fails.
This commit is contained in:
Alexei Podtelezhnikov 2024-04-17 00:33:14 -04:00
parent b3a6a20a80
commit d091bca546
2 changed files with 32 additions and 14 deletions

38
src/cache/ftcmanag.c vendored
View File

@ -118,14 +118,21 @@
FT_Pointer ftcscaler,
FT_Pointer ftcmanager )
{
FT_Error error;
FT_Size size;
FTC_SizeNode node = (FTC_SizeNode)ftcnode;
FTC_Scaler scaler = (FTC_Scaler)ftcscaler;
FTC_Manager manager = (FTC_Manager)ftcmanager;
node->scaler = scaler[0];
error = ftc_scaler_lookup_size( manager, scaler, &size );
if ( !error )
{
node->size = size;
node->scaler = scaler[0];
}
return ftc_scaler_lookup_size( manager, scaler, &node->size );
return error;
}
@ -134,16 +141,23 @@
FT_Pointer ftcscaler,
FT_Pointer ftcmanager )
{
FT_Error error;
FT_Size size;
FTC_SizeNode node = (FTC_SizeNode)ftcnode;
FTC_Scaler scaler = (FTC_Scaler)ftcscaler;
FTC_Manager manager = (FTC_Manager)ftcmanager;
FT_Done_Size( node->size );
error = ftc_scaler_lookup_size( manager, scaler, &size );
if ( !error )
{
FT_Done_Size( node->size );
node->scaler = scaler[0];
node->size = size;
node->scaler = scaler[0];
}
return ftc_scaler_lookup_size( manager, scaler, &node->size );
return error;
}
@ -231,23 +245,25 @@
FT_Pointer ftcface_id,
FT_Pointer ftcmanager )
{
FT_Error error;
FT_Face face;
FTC_FaceNode node = (FTC_FaceNode)ftcnode;
FTC_FaceID face_id = (FTC_FaceID)ftcface_id;
FTC_Manager manager = (FTC_Manager)ftcmanager;
FT_Error error;
node->face_id = face_id;
error = manager->request_face( face_id,
manager->library,
manager->request_data,
&node->face );
&face );
if ( !error )
{
/* destroy initial size object; it will be re-created later */
if ( node->face->size )
FT_Done_Size( node->face->size );
if ( face->size )
FT_Done_Size( face->size );
node->face = face;
node->face_id = face_id;
}
return error;

8
src/cache/ftcmru.c vendored
View File

@ -249,11 +249,13 @@
if ( list->clazz.node_reset )
{
FTC_MruNode_Up( &list->nodes, node );
error = list->clazz.node_reset( node, key, list->data );
if ( !error )
goto Exit;
FTC_MruNode_Up( &list->nodes, node );
else
node = NULL;
goto Exit;
}
FTC_MruNode_Remove( &list->nodes, node );