Commit 04edbbda3cdf2ac0c7b90203ea87549e6f90753b

Werner Lemberg 2014-11-25T10:21:13

*/*: s/Invalid_Argument/Invalid_Face_Handle/ where appropriate.

diff --git a/ChangeLog b/ChangeLog
index 93ee74e..29ea4c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-25  Werner Lemberg  <wl@gnu.org>
+
+	*/*: s/Invalid_Argument/Invalid_Face_Handle/ where appropriate.
+
 2014-11-24  Werner Lemberg  <wl@gnu.org>
 
 	[Savannah bug #43682] Adjust some renderer callbacks.
@@ -9,7 +13,7 @@
 	for orthogonality.
 	(ft_grays_raster): Use it.
 
-2014-11-24  Werner Lemberg  <wl@gnu.org>
+2014-11-25  Werner Lemberg  <wl@gnu.org>
 
 	[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  <wl@gnu.org>
+2014-11-25  Werner Lemberg  <wl@gnu.org>
 
 	[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  <wl@gnu.org>
+2014-11-25  Werner Lemberg  <wl@gnu.org>
 
 	[Savannah bug #43682] Change some signatures to `void' return type.
 
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index 181cf55..81ece38 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 5207847..18884ef 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 5755f85..6b53432 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 <ft2build.h>
+#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;
 
+    FT_Service_BDF  service;
 
-    error = FT_ERR( Invalid_Argument );
-
-    if ( face )
-    {
-      FT_Service_BDF  service;
 
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
 
-      FT_FACE_FIND_SERVICE( face, service, BDF );
+    FT_FACE_FIND_SERVICE( face, service, BDF );
 
-      if ( service && service->get_charset_id )
-        error = service->get_charset_id( face, &encoding, &registry );
-    }
+    if ( service && service->get_charset_id )
+      error = service->get_charset_id( face, &encoding, &registry );
 
     if ( acharset_encoding )
       *acharset_encoding = encoding;
@@ -65,23 +64,23 @@
   {
     FT_Error  error;
 
+    FT_Service_BDF  service;
 
-    error = FT_ERR( Invalid_Argument );
 
-    aproperty->type = BDF_PROPERTY_TYPE_NONE;
+    if ( !face )
+      return FT_THROW( Invalid_Face_Handle );
 
-    if ( face )
-    {
-      FT_Service_BDF  service;
+    if ( !aproperty )
+      return FT_THROW( Invalid_Argument );
 
+    aproperty->type = BDF_PROPERTY_TYPE_NONE;
 
-      FT_FACE_FIND_SERVICE( face, service, BDF );
+    FT_FACE_FIND_SERVICE( face, service, BDF );
 
-      if ( service && service->get_property )
-        error = service->get_property( face, prop_name, aproperty );
-    }
+    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 3c107e4..b73957b 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 0ba955f..ddb58c1 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 c270d59..55a428c 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 5183f6f..96f6912 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 af8824f..64e433d 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 fd5cc4a..f90b084 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;
     }