From 188019eb701c4be4045d77a55f1120e7c73a67da Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Tue, 17 Jan 2023 16:04:30 -0500 Subject: [base] Return error if requested driver is not found. In `open_face_from_buffer` it is possible that a driver is requested but FreeType was built without the requested module. Return an error in this case to indicate that the request could not be satisfied, rather than trying all existing driver modules. * src/base/ftobjs.c (open_face_from_buffer): Return `FT_Err_Missing_Module` if a driver is specified but not found. --- src/base/ftobjs.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 81590f741..aecbcf965 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1731,29 +1731,36 @@ { FT_Open_Args args; FT_Error error; - FT_Stream stream = NULL; FT_Memory memory = library->memory; + args.flags = 0; + + if ( driver_name ) + { + args.driver = FT_Get_Module( library, driver_name ); + if ( !args.driver ) + { + FT_FREE( base ); + return FT_THROW( Missing_Module ); + } + + args.flags = args.flags | FT_OPEN_DRIVER; + } + /* `memory_stream_close` also frees the stream object. */ error = new_memory_stream( library, base, size, memory_stream_close, - &stream ); + &args.stream ); if ( error ) { FT_FREE( base ); return error; } - args.flags = FT_OPEN_STREAM; - args.stream = stream; - if ( driver_name ) - { - args.flags = args.flags | FT_OPEN_DRIVER; - args.driver = FT_Get_Module( library, driver_name ); - } + args.flags |= FT_OPEN_STREAM; #ifdef FT_MACINTOSH /* At this point, the face index has served its purpose; */ -- cgit v1.2.1