From 0614febcec522c608a3d4d62cb5eac544af1a4f6 Mon Sep 17 00:00:00 2001 From: suzuki toshiya Date: Sun, 15 Jan 2012 01:29:41 +0900 Subject: [PATCH] [base] Insert explict cast for GCC 4.6 in PIC mode. * src/base/ftinit.c (FT_Add_Default_Modules): Under PIC configuration, FT_DEFAULT_MODULES_GET returns FT_Module_Class** pointer, GCC 4.6 warns that const FT_Module_Class* const* variable is warned as inappropriate to store it. To calm it, explicit cast is inserted. Also `library' is checked to prevent the NULL pointer dereference in FT_DEFAULT_MODULES_GET. --- ChangeLog | 12 ++++++++++++ src/base/ftinit.c | 13 +++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c0a3b4d9..bbb205b34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2012-01-14 suzuki toshiya + + [base] Insert explict cast for GCC 4.6 in PIC mode. + + * src/base/ftinit.c (FT_Add_Default_Modules): Under PIC + configuration, FT_DEFAULT_MODULES_GET returns + FT_Module_Class** pointer, GCC 4.6 warns that + const FT_Module_Class* const* variable is warned as + inappropriate to store it. To calm it, explicit cast is + inserted. Also `library' is checked to prevent the NULL + pointer dereference in FT_DEFAULT_MODULES_GET. + 2012-01-13 suzuki toshiya Fix PIC build broken by d9145241fe378104ba4c12a42534549faacc92e6. diff --git a/src/base/ftinit.c b/src/base/ftinit.c index 305177a7e..6711b6e9c 100644 --- a/src/base/ftinit.c +++ b/src/base/ftinit.c @@ -181,9 +181,18 @@ Exit: const FT_Module_Class* const* cur; - /* test for valid `library' delayed to FT_Add_Module() */ + /* FT_DEFAULT_MODULES_GET derefers `library' in PIC mode */ +#ifdef FT_CONFIG_OPTION_PIC + if ( !library ) + return; +#endif - cur = FT_DEFAULT_MODULES_GET; + /* GCC 4.6 warns the type difference: + * FT_Module_Class** != const FT_Module_Class* const* + */ + cur = ( const FT_Module_Class* const* )FT_DEFAULT_MODULES_GET; + + /* test for valid `library' delayed to FT_Add_Module() */ while ( *cur ) { error = FT_Add_Module( library, *cur );