diff options
author | Shailesh Mistry <shailesh.mistry@hotmail.co.uk> | 2018-05-15 21:36:30 +0100 |
---|---|---|
committer | Shailesh Mistry <shailesh.mistry@hotmail.co.uk> | 2018-05-16 20:42:31 +0100 |
commit | f90f090c0a5c3e5744d3ec6f0430fbe1a86ac44c (patch) | |
tree | 09a09cffbeb723f579da9a1a5f9d2ab498e68008 /freetype | |
parent | 43f429a2508e72d36a3b27671c8d7e43f1bbc591 (diff) | |
download | ghostpdl-f90f090c0a5c3e5744d3ec6f0430fbe1a86ac44c.tar.gz |
Bug 697545 : Prevent SEGV in freetype if running out of memory.
Prevent SEGV when trying to use buffer after memory failure. This patch has
been accepted by the freetype team as commit e0015f7612cf07ff80561475321ce1f98c7c2b88
Error created using :-
MEMENTO_FAILAT=17104 ./membin/gpcl6 -sDEVICE=pbmraw -dMaxBitmap=2000 -o /dev/null ./tests_private/pcl/pcl5cfts/fts.0051
Diffstat (limited to 'freetype')
-rw-r--r-- | freetype/src/autofit/afcjk.c | 40 | ||||
-rw-r--r-- | freetype/src/autofit/aflatin.c | 42 | ||||
-rw-r--r-- | freetype/src/autofit/afshaper.c | 15 |
3 files changed, 75 insertions, 22 deletions
diff --git a/freetype/src/autofit/afcjk.c b/freetype/src/autofit/afcjk.c index 4823c1d7f..10f670482 100644 --- a/freetype/src/autofit/afcjk.c +++ b/freetype/src/autofit/afcjk.c @@ -100,15 +100,26 @@ AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET [style_class->script]; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif + const char* p; #ifdef FT_DEBUG_LEVEL_TRACE FT_ULong ch = 0; #endif - p = script_class->standard_charstring; + p = script_class->standard_charstring; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif /* We check a list of standard characters. The first match wins. */ @@ -296,7 +307,14 @@ AF_Blue_Stringset bss = sc->blue_stringset; const AF_Blue_StringRec* bs = &af_blue_stringsets[bss]; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* we walk over the blue character strings as specified in the */ @@ -307,7 +325,9 @@ "==========================\n" "\n" )); +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ ) { @@ -565,15 +585,25 @@ FT_Bool started = 0, same_width = 1; FT_Fixed advance, old_advance = 0; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* in all supported charmaps, digits have character codes 0x30-0x39 */ const char digits[] = "0 1 2 3 4 5 6 7 8 9"; const char* p; - p = digits; + p = digits; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif while ( *p ) { diff --git a/freetype/src/autofit/aflatin.c b/freetype/src/autofit/aflatin.c index db7aaff7b..aef4dcc09 100644 --- a/freetype/src/autofit/aflatin.c +++ b/freetype/src/autofit/aflatin.c @@ -91,16 +91,27 @@ AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET [style_class->script]; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif + const char* p; #ifdef FT_DEBUG_LEVEL_TRACE FT_ULong ch = 0; #endif - p = script_class->standard_charstring; - shaper_buf = af_shaper_buf_create( face ); + p = script_class->standard_charstring; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + shaper_buf = af_shaper_buf_create( face ); +#endif /* * We check a list of standard characters to catch features like * `c2sc' (small caps from caps) that don't contain lowercase letters @@ -290,7 +301,14 @@ FT_Pos flat_threshold = FLAT_THRESHOLD( metrics->units_per_em ); - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* we walk over the blue character strings as specified in the */ @@ -300,7 +318,9 @@ "============================\n" "\n" )); +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ ) { @@ -943,15 +963,25 @@ FT_Bool started = 0, same_width = 1; FT_Fixed advance, old_advance = 0; - void* shaper_buf; + /* If HarfBuzz is not available, we need a pointer to a single */ + /* unsigned long value. */ +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ + void* shaper_buf; +#else + FT_ULong shaper_buf_; + void* shaper_buf = &shaper_buf_; +#endif /* in all supported charmaps, digits have character codes 0x30-0x39 */ const char digits[] = "0 1 2 3 4 5 6 7 8 9"; const char* p; - p = digits; + p = digits; + +#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ shaper_buf = af_shaper_buf_create( face ); +#endif while ( *p ) { diff --git a/freetype/src/autofit/afshaper.c b/freetype/src/autofit/afshaper.c index 6d13b6585..cbad1b769 100644 --- a/freetype/src/autofit/afshaper.c +++ b/freetype/src/autofit/afshaper.c @@ -591,14 +591,9 @@ void* af_shaper_buf_create( FT_Face face ) { - FT_Error error; - FT_Memory memory = face->memory; - FT_ULong* buf; - - - FT_MEM_ALLOC( buf, sizeof ( FT_ULong ) ); + FT_UNUSED( face ); - return (void*)buf; + return NULL; } @@ -606,10 +601,8 @@ af_shaper_buf_destroy( FT_Face face, void* buf ) { - FT_Memory memory = face->memory; - - - FT_FREE( buf ); + FT_UNUSED( face ); + FT_UNUSED( buf ); } |