* src/base/ftpfr.c (FT_Get_PFR_Metrics): Protect against NULL arguments. Fix return value for non-PFR fonts. Both problems reported by Chi Nguyen <chint@necsv.com>.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
diff --git a/ChangeLog b/ChangeLog
index 7092d84..f6ff3cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-21 Werner Lemberg <wl@gnu.org>
+
+ * src/base/ftpfr.c (FT_Get_PFR_Metrics): Protect against NULL
+ arguments.
+ Fix return value for non-PFR fonts. Both problems reported by Chi
+ Nguyen <chint@necsv.com>.
+
2008-12-21 anonymous
FT_USE_MODULE declares things as:
diff --git a/include/freetype/ftpfr.h b/include/freetype/ftpfr.h
index 8e79a79..02b1bdf 100644
--- a/include/freetype/ftpfr.h
+++ b/include/freetype/ftpfr.h
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing PFR-specific data (specification only). */
/* */
-/* Copyright 2002, 2003, 2004, 2006 by */
+/* Copyright 2002, 2003, 2004, 2006, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -73,11 +73,11 @@ FT_BEGIN_HEADER
* A 16.16 fixed-point number used to scale distance expressed
* in metrics units to device sub-pixels. This is equivalent to
* `face->size->x_scale', but for metrics only. Optional (parameter
- * can be NULL)
+ * can be NULL).
*
* ametrics_y_scale ::
* Same as `ametrics_x_scale' but for the vertical direction.
- * optional (parameter can be NULL)
+ * optional (parameter can be NULL).
*
* @return:
* FreeType error code. 0~means success.
diff --git a/src/base/ftpfr.c b/src/base/ftpfr.c
index 9e930dd..f9592bb 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, 2003, 2004 by */
+/* Copyright 2002, 2003, 2004, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -46,6 +46,9 @@
FT_Service_PfrMetrics service;
+ if ( !face )
+ return FT_Err_Invalid_Argument;
+
service = ft_pfr_check( face );
if ( service )
{
@@ -55,14 +58,17 @@
ametrics_x_scale,
ametrics_y_scale );
}
- else if ( face )
+ else
{
FT_Fixed x_scale, y_scale;
/* this is not a PFR font */
- *aoutline_resolution = face->units_per_EM;
- *ametrics_resolution = face->units_per_EM;
+ if ( aoutline_resolution )
+ *aoutline_resolution = face->units_per_EM;
+
+ if ( ametrics_resolution )
+ *ametrics_resolution = face->units_per_EM;
x_scale = y_scale = 0x10000L;
if ( face->size )
@@ -70,11 +76,15 @@
x_scale = face->size->metrics.x_scale;
y_scale = face->size->metrics.y_scale;
}
- *ametrics_x_scale = x_scale;
- *ametrics_y_scale = y_scale;
+
+ if ( ametrics_x_scale )
+ *ametrics_x_scale = x_scale;
+
+ if ( ametrics_y_scale )
+ *ametrics_y_scale = y_scale;
+
+ error = FT_Err_Unknown_File_Format;
}
- else
- error = FT_Err_Invalid_Argument;
return error;
}
@@ -92,14 +102,15 @@
FT_Service_PfrMetrics service;
+ if ( !face )
+ return FT_Err_Invalid_Argument;
+
service = ft_pfr_check( face );
if ( service )
error = service->get_kerning( face, left, right, avector );
- else if ( face )
+ else
error = FT_Get_Kerning( face, left, right,
FT_KERNING_UNSCALED, avector );
- else
- error = FT_Err_Invalid_Argument;
return error;
}