[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Jul 11 20:38:44 UTC 2016


 src/hb-ft.cc |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 6bf9db4f1e1d51f9acb5e37b89caa8f4d275e7ce
Author: Birunthan Mohanathas <birunthan at mohanathas.com>
Date:   Mon Jul 11 13:38:23 2016 -0700

    [ft] Fix unsafe cast of FT_Done_Face in hb_ft_{face,font}_create_referenced (#289)
    
    Prior to this change the function `FT_Error FT_Done_Face(FT_Face *)` was
    called through a pointer with the signature `void (void *)` resulting in
    undefined behaviour.

diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index 2cad8c2..6c6749c 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -90,10 +90,16 @@ _hb_ft_font_create (FT_Face ft_face, bool unref)
 }
 
 static void
+_hb_ft_face_destroy (FT_Face ft_face)
+{
+  FT_Done_Face (ft_face);
+}
+
+static void
 _hb_ft_font_destroy (hb_ft_font_t *ft_font)
 {
   if (ft_font->unref)
-    FT_Done_Face (ft_font->ft_face);
+    _hb_ft_face_destroy (ft_font->ft_face);
 
   free (ft_font);
 }
@@ -526,7 +532,7 @@ hb_face_t *
 hb_ft_face_create_referenced (FT_Face ft_face)
 {
   FT_Reference_Face (ft_face);
-  return hb_ft_face_create (ft_face, (hb_destroy_func_t) FT_Done_Face);
+  return hb_ft_face_create (ft_face, (hb_destroy_func_t) _hb_ft_face_destroy);
 }
 
 static void
@@ -606,7 +612,7 @@ hb_font_t *
 hb_ft_font_create_referenced (FT_Face ft_face)
 {
   FT_Reference_Face (ft_face);
-  return hb_ft_font_create (ft_face, (hb_destroy_func_t) FT_Done_Face);
+  return hb_ft_font_create (ft_face, (hb_destroy_func_t) _hb_ft_face_destroy);
 }
 
 


More information about the HarfBuzz mailing list