From 04edbbda3cdf2ac0c7b90203ea87549e6f90753b Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Tue, 25 Nov 2014 10:21:13 +0100 Subject: [PATCH] */*: s/Invalid_Argument/Invalid_Face_Handle/ where appropriate. --- ChangeLog | 10 +++++++--- src/autofit/afmodule.c | 2 +- src/base/ftadvanc.c | 8 +++++++- src/base/ftbdf.c | 43 ++++++++++++++++++++--------------------- src/base/ftobjs.c | 9 ++++++--- src/base/ftpfr.c | 6 +++--- src/bdf/bdfdrivr.c | 8 +++++++- src/pcf/pcfdrivr.c | 8 +++++++- src/truetype/ttdriver.c | 2 +- src/winfonts/winfnt.c | 2 +- 10 files changed, 61 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93ee74e4c..29ea4c6d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-11-25 Werner Lemberg + + */*: s/Invalid_Argument/Invalid_Face_Handle/ where appropriate. + 2014-11-24 Werner Lemberg [Savannah bug #43682] Adjust some renderer callbacks. @@ -9,7 +13,7 @@ for orthogonality. (ft_grays_raster): Use it. -2014-11-24 Werner Lemberg +2014-11-25 Werner Lemberg [Savannah bug #43682] Properly handle missing return errors. @@ -25,7 +29,7 @@ TT_Load_Glyph), src/truetype/ttgxvar.c (TT_Set_MM_Blend), src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): Do it. -2014-11-24 Werner Lemberg +2014-11-25 Werner Lemberg [Savannah bug #43682] Add/remove `void' casts to some functions. @@ -39,7 +43,7 @@ src/type1/t1load.c (parse_encoding), src/type42/t42parse.c (t42_parse_encoding): Do it. -2014-11-24 Werner Lemberg +2014-11-25 Werner Lemberg [Savannah bug #43682] Change some signatures to `void' return type. diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c index 181cf553e..81ece3851 100644 --- a/src/autofit/afmodule.c +++ b/src/autofit/afmodule.c @@ -55,7 +55,7 @@ if ( !face ) - return FT_THROW( Invalid_Argument ); + return FT_THROW( Invalid_Face_Handle ); globals = (AF_FaceGlobals)face->autohint.data; if ( !globals ) diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c index 52078478d..18884efe1 100644 --- a/src/base/ftadvanc.c +++ b/src/base/ftadvanc.c @@ -4,7 +4,7 @@ /* */ /* Quick computation of advance widths (body). */ /* */ -/* Copyright 2008, 2009, 2011, 2013 by */ +/* Copyright 2008, 2009, 2011, 2013, 2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -80,6 +80,9 @@ if ( !face ) return FT_THROW( Invalid_Face_Handle ); + if ( !padvance ) + return FT_THROW( Invalid_Argument ); + if ( gindex >= (FT_UInt)face->num_glyphs ) return FT_THROW( Invalid_Glyph_Index ); @@ -118,6 +121,9 @@ if ( !face ) return FT_THROW( Invalid_Face_Handle ); + if ( !padvances ) + return FT_THROW( Invalid_Argument ); + num = (FT_UInt)face->num_glyphs; end = start + count; if ( start >= num || end < start || end > num ) diff --git a/src/base/ftbdf.c b/src/base/ftbdf.c index 5755f8558..6b53432ea 100644 --- a/src/base/ftbdf.c +++ b/src/base/ftbdf.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing BDF-specific strings (body). */ /* */ -/* Copyright 2002-2004, 2013 by */ +/* Copyright 2002-2004, 2013, 2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -17,6 +17,8 @@ #include +#include FT_INTERNAL_DEBUG_H + #include FT_INTERNAL_OBJECTS_H #include FT_SERVICE_BDF_H @@ -32,19 +34,16 @@ const char* encoding = NULL; const char* registry = NULL; - - error = FT_ERR( Invalid_Argument ); - - if ( face ) - { - FT_Service_BDF service; + FT_Service_BDF service; - FT_FACE_FIND_SERVICE( face, service, BDF ); + if ( !face ) + return FT_THROW( Invalid_Face_Handle ); - if ( service && service->get_charset_id ) - error = service->get_charset_id( face, &encoding, ®istry ); - } + FT_FACE_FIND_SERVICE( face, service, BDF ); + + if ( service && service->get_charset_id ) + error = service->get_charset_id( face, &encoding, ®istry ); if ( acharset_encoding ) *acharset_encoding = encoding; @@ -65,23 +64,23 @@ { FT_Error error; + FT_Service_BDF service; - error = FT_ERR( Invalid_Argument ); + + if ( !face ) + return FT_THROW( Invalid_Face_Handle ); + + if ( !aproperty ) + return FT_THROW( Invalid_Argument ); aproperty->type = BDF_PROPERTY_TYPE_NONE; - if ( face ) - { - FT_Service_BDF service; + FT_FACE_FIND_SERVICE( face, service, BDF ); + if ( service && service->get_property ) + error = service->get_property( face, prop_name, aproperty ); - FT_FACE_FIND_SERVICE( face, service, BDF ); - - if ( service && service->get_property ) - error = service->get_property( face, prop_name, aproperty ); - } - - return error; + return error; } diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 3c107e407..b73957b2a 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -408,7 +408,10 @@ FT_GlyphSlot slot = NULL; - if ( !face || !face->driver ) + if ( !face ) + return FT_THROW( Invalid_Face_Handle ); + + if ( !face->driver ) return FT_THROW( Invalid_Argument ); driver = face->driver; @@ -3630,7 +3633,7 @@ FT_Get_Sfnt_Table( FT_Face face, FT_Sfnt_Tag tag ) { - void* table = 0; + void* table = NULL; FT_Service_SFNT_Table service; @@ -3752,7 +3755,7 @@ face = size->face; if ( !face || !face->driver ) - return FT_THROW( Invalid_Argument ); + return FT_THROW( Invalid_Face_Handle ); /* we don't need anything more complex than that; all size objects */ /* are already listed by the face */ diff --git a/src/base/ftpfr.c b/src/base/ftpfr.c index 0ba955f01..ddb58c17b 100644 --- a/src/base/ftpfr.c +++ b/src/base/ftpfr.c @@ -4,7 +4,7 @@ /* */ /* FreeType API for accessing PFR-specific data (body). */ /* */ -/* Copyright 2002-2004, 2008, 2010, 2013 by */ +/* Copyright 2002-2004, 2008, 2010, 2013, 2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -50,7 +50,7 @@ if ( !face ) - return FT_THROW( Invalid_Argument ); + return FT_THROW( Invalid_Face_Handle ); service = ft_pfr_check( face ); if ( service ) @@ -106,7 +106,7 @@ if ( !face ) - return FT_THROW( Invalid_Argument ); + return FT_THROW( Invalid_Face_Handle ); service = ft_pfr_check( face ); if ( service ) diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c index c270d5976..55a428c1b 100644 --- a/src/bdf/bdfdrivr.c +++ b/src/bdf/bdfdrivr.c @@ -679,7 +679,13 @@ THE SOFTWARE. FT_UNUSED( load_flags ); - if ( !face || glyph_index >= (FT_UInt)face->num_glyphs ) + if ( !face ) + { + error = FT_THROW( Invalid_Face_Handle ); + goto Exit; + } + + if ( glyph_index >= (FT_UInt)face->num_glyphs ) { error = FT_THROW( Invalid_Argument ); goto Exit; diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c index 5183f6f50..96f6912ba 100644 --- a/src/pcf/pcfdrivr.c +++ b/src/pcf/pcfdrivr.c @@ -494,7 +494,13 @@ THE SOFTWARE. FT_TRACE1(( "PCF_Glyph_Load: glyph index %d\n", glyph_index )); - if ( !face || glyph_index >= (FT_UInt)face->root.num_glyphs ) + if ( !face ) + { + error = FT_THROW( Invalid_Face_Handle ); + goto Exit; + } + + if ( glyph_index >= (FT_UInt)face->root.num_glyphs ) { error = FT_THROW( Invalid_Argument ); goto Exit; diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index af8824f9e..64e433db0 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -370,7 +370,7 @@ return FT_THROW( Invalid_Size_Handle ); if ( !face ) - return FT_THROW( Invalid_Argument ); + return FT_THROW( Invalid_Face_Handle ); #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( glyph_index >= (FT_UInt)face->num_glyphs && diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c index fd5cc4a1a..f90b084db 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -974,7 +974,7 @@ if ( !face ) { - error = FT_THROW( Invalid_Argument ); + error = FT_THROW( Invalid_Face_Handle ); goto Exit; }