From: Antony Dovgal Date: Wed, 21 Feb 2007 18:41:23 +0000 (+0000) Subject: MFH: fix #40578 (imagettftext() multithreading issue) X-Git-Tag: php-4.4.6RC1~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc733cb576d3ce52d6bde94ac1f196d33a0a3b0c;p=php MFH: fix #40578 (imagettftext() multithreading issue) --- diff --git a/NEWS b/NEWS index a25c4c5574..99f9b29f96 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ PHP 4 NEWS ?? ??? 2007, Version 4.4.6 - Updated PCRE to version 7.0. (Nuno) - Fixed segfault in ext/session when register_globals=On. (Tony) +- Fixed bug #40578 (imagettftext() multithreading issue). (Tony) - Fixed bug #40502 (ext/interbase compile failure). (Tony) - Fixed bug #40286 (PHP fastcgi with PHP_FCGI_CHILDREN don't kill children when parent is killed). (Dmitry) diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index ccf1a91f5d..f38c8f291a 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -196,6 +196,16 @@ tweencolorkey_t; #include "jisx0208.h" #endif +extern int any2eucjp (char *, char *, unsigned int); + +/* Persistent font cache until explicitly cleared */ +/* Fonts can be used across multiple images */ + +/* 2.0.16: thread safety (the font cache is shared) */ +gdMutexDeclare(gdFontCacheMutex); +static gdCache_head_t *fontCache = NULL; +static FT_Library library; + #define Tcl_UniChar int #define TCL_UTF_MAX 3 static int @@ -740,9 +750,10 @@ gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitm /* find antialised color */ tc_key.bgcolor = *pixel; - tc_elem = (tweencolor_t *) gdCacheGet ( - tc_cache, &tc_key); + gdMutexLock(gdFontCacheMutex); + tc_elem = (tweencolor_t *) gdCacheGet (tc_cache, &tc_key); *pixel = tc_elem->tweencolor; + gdMutexUnlock(gdFontCacheMutex); } } } @@ -758,16 +769,6 @@ gdroundupdown (FT_F26Dot6 v1, int updown) : (v1 > 0 ? ((v1 + 63) >> 6) : v1 >> 6); } -extern int any2eucjp (char *, char *, unsigned int); - -/* Persistent font cache until explicitly cleared */ -/* Fonts can be used across multiple images */ - -/* 2.0.16: thread safety (the font cache is shared) */ -gdMutexDeclare(gdFontCacheMutex); -static gdCache_head_t *fontCache = NULL; -static FT_Library library; - void gdFontCacheShutdown() { if (fontCache) {