diff options
author | Ben Wagner <bungeman@chromium.org> | 2023-01-17 16:04:30 -0500 |
---|---|---|
committer | Werner Lemberg <wl@gnu.org> | 2023-01-18 08:37:51 +0100 |
commit | 188019eb701c4be4045d77a55f1120e7c73a67da (patch) | |
tree | fbcbd6bdd57b364f826dff112d64572e4c555408 /src | |
parent | a297feab0e7cdd8e9fa88965cd8d9591f5e6b4d3 (diff) | |
download | freetype2-188019eb701c4be4045d77a55f1120e7c73a67da.tar.gz |
[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.
Diffstat (limited to 'src')
-rw-r--r-- | src/base/ftobjs.c | 25 |
1 files 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; */ |