freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 188019eb7: [base] Return error if requested driver is


From: Werner Lemberg
Subject: [freetype2] master 188019eb7: [base] Return error if requested driver is not found.
Date: Wed, 18 Jan 2023 02:55:15 -0500 (EST)

branch: master
commit 188019eb701c4be4045d77a55f1120e7c73a67da
Author: Ben Wagner <bungeman@chromium.org>
Commit: Werner Lemberg <wl@gnu.org>

    [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;  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]