Commit d9145241fe378104ba4c12a42534549faacc92e6

suzuki toshiya 2010-02-05T02:58:24

Prevent NULL pointer dereference passed to FT_Module_Requester.

diff --git a/ChangeLog b/ChangeLog
index c2dea8f..f02fc70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-02-04  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+	Prevent NULL pointer dereference passed to FT_Module_Requester.
+
+	* src/sfnt/sfdriver.c (sfnt_get_interface): Don't use `module'.
+	* src/psnames/psmodule.c (psnames_get_interface): Ditto.
+
+	* src/cff/cffdrivr.c (cff_get_interface): Check NULL `driver'.
+	* src/truetype/ttdriver.c (tt_get_interface): Ditto.
+
 2010-01-29  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
 
 	Fix memory leaks in previous patch.
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 217adf2..dad0b65 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -621,14 +621,15 @@
   {
     FT_Module            sfnt;
     FT_Module_Interface  result;
-    FT_Library           library = driver->library;
-    FT_UNUSED(library);
 
 
     result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface );
     if ( result != NULL )
       return  result;
 
+    if ( !driver )
+      return NULL;
+
     /* we pass our request to the `sfnt' module */
     sfnt = FT_Get_Module( driver->library, "sfnt" );
 
diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c
index 3518850..00b363f 100644
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -561,8 +561,7 @@
   psnames_get_service( FT_Module    module,
                        const char*  service_id )
   {
-    FT_Library library = module->library;
-    FT_UNUSED(library);
+    FT_UNUSED( module );
 
     return ft_service_list_lookup( FT_PSCMAPS_SERVICES_GET, service_id );
   }
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 1d157b7..1097efb 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -417,8 +417,6 @@
   sfnt_get_interface( FT_Module    module,
                       const char*  module_interface )
   {
-    FT_Library           library = module->library;
-    FT_UNUSED(library);
     FT_UNUSED( module );
 
     return ft_service_list_lookup( FT_SFNT_SERVICES_GET, module_interface );
diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c
index d4978a9..d723b57 100644
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -402,16 +402,17 @@
   tt_get_interface( FT_Module    driver,    /* TT_Driver */
                     const char*  tt_interface )
   {
-    FT_Library           library = driver->library;
     FT_Module_Interface  result;
     FT_Module            sfntd;
     SFNT_Service         sfnt;
-    FT_UNUSED(library);
 
     result = ft_service_list_lookup( FT_TT_SERVICES_GET, tt_interface );
     if ( result != NULL )
       return result;
 
+    if ( !driver )
+      return NULL;
+
     /* only return the default interface from the SFNT module */
     sfntd = FT_Get_Module( driver->library, "sfnt" );
     if ( sfntd )