[autofit] Fix potential memory leak. While this doesn't show up with FreeType, exactly the same code leaks with ttfautohint's modified auto-hinter code (which gets used in a slightly different way). It certainly doesn't harm since it is similar to already existing checks in the code for embedded arrays. * src/autofit/afhints.c (af_glyph_hints_reload): Set `max_contours' and `max_points' for all cases.
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
diff --git a/ChangeLog b/ChangeLog
index 15cc4c7..bf60542 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2015-02-06 Werner Lemberg <wl@gnu.org>
+
+ [autofit] Fix potential memory leak.
+
+ While this doesn't show up with FreeType, exactly the same code
+ leaks with ttfautohint's modified auto-hinter code (which gets used
+ in a slightly different way).
+
+ It certainly doesn't harm since it is similar to already existing
+ checks in the code for embedded arrays.
+
+ * src/autofit/afhints.c (af_glyph_hints_reload): Set `max_contours'
+ and `max_points' for all cases.
+
2015-01-31 Werner Lemberg <wl@gnu.org>
[autofit] Add support for Thai script.
diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c
index 56bc386..8b0e1b0 100644
--- a/src/autofit/afhints.c
+++ b/src/autofit/afhints.c
@@ -615,7 +615,13 @@
old_max = hints->max_contours;
if ( new_max <= AF_CONTOURS_EMBEDDED )
- hints->contours = hints->embedded.contours;
+ {
+ if ( hints->contours == NULL )
+ {
+ hints->contours = hints->embedded.contours;
+ hints->max_contours = AF_CONTOURS_EMBEDDED;
+ }
+ }
else if ( new_max > old_max )
{
if ( hints->contours == hints->embedded.contours )
@@ -638,7 +644,13 @@
old_max = hints->max_points;
if ( new_max <= AF_POINTS_EMBEDDED )
- hints->points = hints->embedded.points;
+ {
+ if ( hints->points == NULL )
+ {
+ hints->points = hints->embedded.points;
+ hints->max_points = AF_POINTS_EMBEDDED;
+ }
+ }
else if ( new_max > old_max )
{
if ( hints->points == hints->embedded.points )