[Image-SIG] PIL ImageFont segfault mystery

Fredrik Lundh fredrik at pythonware.com
Sun Dec 23 20:38:08 CET 2007


Fredrik Lundh wrote:

> seeing the bug report isn't necessarily the same thing as having time to 
> work on a fix ;-)

as I suspected, the offending files was missing some optional fields; 
freetype2 handled that nicely, but _imagingft module didn't expect the 
fields to be NULL.

here's a tentative patch:

$ svn diff _imagingft.c
Index: _imagingft.c
===================================================================
--- _imagingft.c        (revision 3345)
+++ _imagingft.c        (working copy)
@@ -422,10 +422,11 @@

      /* attributes */
      if (!strcmp(name, "family"))
-        return PyString_FromString(self->face->family_name);
+        return PyString_FromString(self->face->family_name ?
+                                   self->face->family_name : "");
      if (!strcmp(name, "style"))
-        return PyString_FromString(self->face->style_name);
-
+        return PyString_FromString(self->face->style_name ?
+                                   self->face->style_name : "");
      if (!strcmp(name, "ascent"))
          return PyInt_FromLong(PIXEL(self->face->size->metrics.ascender));
      if (!strcmp(name, "descent"))

(might be a better idea to return None in this case, but the above will 
at least prevent the crash).

</F>



More information about the Image-SIG mailing list