[gs-commits] rev 11775 - trunk/gs/psi

chrisl at ghostscript.com chrisl at ghostscript.com
Fri Oct 8 13:31:11 UTC 2010


Author: chrisl
Date: 2010-10-08 13:31:11 +0000 (Fri, 08 Oct 2010)
New Revision: 11775

Modified:
   trunk/gs/psi/fapi_ft.c
Log:
A stringwidth operation does not always result in a call to fapi_finish_render()
which can cause Freetype glyph objects to not be freed.

Add a firewall so we don't simply overwrite the pointer to the Freetype glyph
object, but correctly dispose of the object.

Bug 691668

No cluster differences expected.



Modified: trunk/gs/psi/fapi_ft.c
===================================================================
--- trunk/gs/psi/fapi_ft.c	2010-10-08 12:01:24 UTC (rev 11774)
+++ trunk/gs/psi/fapi_ft.c	2010-10-08 13:31:11 UTC (rev 11775)
@@ -44,7 +44,6 @@
 #include FT_OUTLINE_H
 #include FT_IMAGE_H
 
-
 /* Note: structure definitions here start with FF_, which stands for 'FAPI FreeType". */
 
 typedef struct FF_server_s
@@ -510,7 +509,8 @@
         FT_BitmapGlyph bg = (FT_BitmapGlyph)*a_glyph;
 
         if (bitmap_raster(bg->bitmap.width) * bg->bitmap.rows > max_bitmap) {
-            ft_glyphslot_free_bitmap(ft_face->glyph);
+            FT_Done_Glyph(bg);
+            *a_glyph = NULL;
             return (e_VMerror);
         }
     }
@@ -769,6 +769,16 @@
     FF_face *face = (FF_face*)a_font->server_font_data;
     FT_Error ft_error = 0;
 
+    if (s->bitmap_glyph) {
+        FT_Done_Glyph(&s->bitmap_glyph->root);
+        s->bitmap_glyph = NULL;
+    }
+    if (s->outline_glyph) {
+        FT_Done_Glyph(&s->outline_glyph->root);
+        s->outline_glyph = NULL;
+    }
+    
+
     /* dpf("get_scaled_font enter: is_type1=%d is_cid=%d font_file_path='%s' a_descendant_code=%d\n",
        a_font->is_type1, a_font->is_cid, a_font->font_file_path ? a_font->font_file_path : "", a_descendant_code); */
 
@@ -1022,7 +1032,8 @@
 get_char_width(FAPI_server *a_server, FAPI_font *a_font, FAPI_char_ref *a_char_ref, FAPI_metrics *a_metrics)
 {
     FF_server *s = (FF_server*)a_server;
-    return load_glyph(a_font, a_char_ref, a_metrics, (FT_Glyph*)&s->bitmap_glyph, a_server->max_bitmap > 0 ? true : false, a_server->max_bitmap);
+    return load_glyph(a_font, a_char_ref, a_metrics, a_server->max_bitmap > 0 ? (FT_Glyph*)&s->bitmap_glyph : (FT_Glyph*)&s->outline_glyph,
+                           a_server->max_bitmap > 0 ? true : false, a_server->max_bitmap);
 }
 
 static FAPI_retcode get_fontmatrix(FAPI_server *server, gs_matrix *m)



More information about the gs-commits mailing list