Revision: 6862
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6862&view=rev
Author: jouni
Date: 2009-02-02 08:29:18 +0000 (Mon, 02 Feb 2009)
Log Message:
-----------
Avoid malloc errors in ttconv for fonts that don't have e.g. PostName
as entry (1,0,0,6) in the name table (a version of Tahoma triggered this)
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/ttconv/pprdrv_tt.cpp
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-01-30 16:31:47 UTC (rev 6861)
+++ trunk/matplotlib/CHANGELOG 2009-02-02 08:29:18 UTC (rev 6862)
@@ -1,3 +1,6 @@
+2009-02-02 Avoid malloc errors in ttconv for fonts that don't have
+ e.g. PostName (a version of Tahoma triggered this) - JKS
+
2009-01-30 Remove support for pyExcelerator in exceltools -- use xlwt
instead - JDH
Modified: trunk/matplotlib/ttconv/pprdrv_tt.cpp
===================================================================
--- trunk/matplotlib/ttconv/pprdrv_tt.cpp 2009-01-30 16:31:47 UTC (rev
6861)
+++ trunk/matplotlib/ttconv/pprdrv_tt.cpp 2009-02-02 08:29:18 UTC (rev
6862)
@@ -178,10 +178,18 @@
table_ptr = NULL;
- /* Set default values to avoid future references to */
- /* undefined pointers. */
- font->PostName = font->FullName =
- font->FamilyName = font->Version = font->Style = (char*)"unknown";
+ /* Set default values to avoid future references to undefined
+ * pointers. Allocate each of PostName, FullName, FamilyName,
+ * Version, and Style separately so they can be freed safely. */
+ for (char **ptr = &(font->PostName); ptr != NULL; ) {
+ *ptr = (char*) calloc(sizeof(char), strlen("unknown")+1);
+ strcpy(*ptr, "unknown");
+ if (ptr == &(font->PostName)) ptr = &(font->FullName);
+ else if (ptr == &(font->FullName)) ptr = &(font->FamilyName);
+ else if (ptr == &(font->FamilyName)) ptr = &(font->Version);
+ else if (ptr == &(font->Version)) ptr = &(font->Style);
+ else ptr = NULL;
+ }
font->Copyright = font->Trademark = (char*)NULL;
table_ptr = GetTable(font, "name"); /* pointer to table */
@@ -222,6 +230,7 @@
/* Font Family name */
if( platform == 1 && nameid == 1 )
{
+ free(font->FamilyName);
font->FamilyName = (char*)calloc(sizeof(char),length+1);
strncpy(font->FamilyName,(const char*)strings+offset,length);
font->FamilyName[length]=(char)NULL;
@@ -237,6 +246,7 @@
/* Font Family name */
if( platform == 1 && nameid == 2 )
{
+ free(font->Style);
font->Style = (char*)calloc(sizeof(char),length+1);
strncpy(font->Style,(const char*)strings+offset,length);
font->Style[length]=(char)NULL;
@@ -252,6 +262,7 @@
/* Full Font name */
if( platform == 1 && nameid == 4 )
{
+ free(font->FullName);
font->FullName = (char*)calloc(sizeof(char),length+1);
strncpy(font->FullName,(const char*)strings+offset,length);
font->FullName[length]=(char)NULL;
@@ -267,6 +278,7 @@
/* Version string */
if( platform == 1 && nameid == 5 )
{
+ free(font->Version);
font->Version = (char*)calloc(sizeof(char),length+1);
strncpy(font->Version,(const char*)strings+offset,length);
font->Version[length]=(char)NULL;
@@ -282,6 +294,7 @@
/* PostScript name */
if( platform == 1 && nameid == 6 )
{
+ free(font->PostName);
font->PostName = (char*)calloc(sizeof(char),length+1);
strncpy(font->PostName,(const char*)strings+offset,length);
font->PostName[length]=(char)NULL;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins