From 40a1221114cf0600599431167bea3fa062e87417 Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Sat, 19 Apr 2014 18:36:26 +0000 Subject: [PATCH] Ignoring ".pfb" (PostScript 'Printer Font Binary') fonts, to avoid crashes. --- docs/CHANGES.txt | 5 ++++- src/fonts.c | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 1d28b8978..86f3538ed 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -8,7 +8,7 @@ http://www.tuxpaint.org/ $Id$ -2014.April.16 (0.9.22) +2014.April.19 (0.9.22) * New Tools: ---------- @@ -623,6 +623,9 @@ $Id$ * Saved images woose path contains non-ascii chars can now be opened on Windows. Fixes http://sourceforge.net/p/tuxpaint/bugs/188/ + * Ignoring ".pfb" (PostScript 'Printer Font Binary') fonts, to + avoid crashes. + 2009.June.28 (0.9.21) * New Starters: ------------- diff --git a/src/fonts.c b/src/fonts.c index dd9edd0a6..7f0dbcae9 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -83,6 +83,12 @@ static const char *problemFonts[] = { NULL }; +/* font types that cause TTF_OpenFont to crash */ +static const char *problemFontExtensions[] = { + ".pfb", /* Ubuntu 14.04 (libsdl-ttf2.0-0 2.0.11-3, libfreetype6 2.5.2-1ubuntu2) -bjk 2014.04.19 */ + NULL +}; + #ifdef FORKED_FONTS #include @@ -270,7 +276,7 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffilename, int size) { TuxPaint_Font *tpf = NULL; - int i = 0; + int i; #ifndef NO_SDLPANGO char desc[1024]; #endif @@ -320,12 +326,20 @@ TuxPaint_Font *TuxPaint_Font_OpenFont(const char *pangodesc, const char *ttffile fflush(stdout); #endif + i = 0; while (problemFonts[i] != NULL) { if (!strcmp(ttffilename, problemFonts[i++])) return NULL; /* bail on known problematic fonts that cause TTF_OpenFont to crash */ } + i = 0; + while (problemFontExtensions[i] != NULL) + { + if (strstr(ttffilename, problemFontExtensions[i++])) + return NULL; /* bail on known problematic font types that cause TTF_OpenFont to crash */ + } + tpf = (TuxPaint_Font *) malloc(sizeof(TuxPaint_Font)); tpf->typ = FONT_TYPE_TTF; tpf->ttf_font = TTF_OpenFont(ttffilename, size);