shithub: freetype+ttf2subf

Download patch

ref: b6cb4997e8f0accd98b9589f29e4654e8002501f
parent: 19146a5302a47ee8430a00bfa8c2acaf9539d6a2
author: Werner Lemberg <[email protected]>
date: Fri Feb 6 03:46:06 EST 2015

[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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2015-02-06  Werner Lemberg  <[email protected]>
+
+	[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  <[email protected]>
 
 	[autofit] Add support for Thai script.
--- 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 )