From b6cb4997e8f0accd98b9589f29e4654e8002501f Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 6 Feb 2015 08:46:06 +0100 Subject: [PATCH] [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. --- ChangeLog | 14 ++++++++++++++ src/autofit/afhints.c | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 15cc4c731..bf605426e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2015-02-06 Werner Lemberg + + [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 [autofit] Add support for Thai script. diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c index 56bc38622..8b0e1b009 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 )