From: Antony Dovgal Date: Wed, 21 Feb 2007 15:00:26 +0000 (+0000) Subject: MFH: fix #40578 (imagettftext() multithreading issue) X-Git-Tag: php-5.2.2RC1~338 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=94bab7b2067d28092ee9e03c3e5b6537cd930dd0;p=php MFH: fix #40578 (imagettftext() multithreading issue) --- diff --git a/NEWS b/NEWS index 61b90265a5..1a18c5365f 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ PHP NEWS - Added --ri switch to CLI which allows to check extension information. (Marcus) - Added tidyNode::getParent() method (John, Nuno) - Fixed zend_llist_remove_tail (Michael Wallner, Dmitry) +- Fixed bug #40578 (imagettftext() multithreading issue). (Tony) - Fixed bug #40576 (double values are truncated to 6 decimal digits when encoding). (Tony) - Fixed bug #40560 (DIR functions do not work on root UNC path). (Dmitry) diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index 30ac2768c9..bf5bd04d12 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -192,6 +192,16 @@ typedef struct #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 gdTcl_UtfToUniChar (char *str, Tcl_UniChar * chPtr) @@ -688,8 +698,10 @@ static char * gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, } else { /* find antialised color */ tc_key.bgcolor = *pixel; + gdMutexLock(gdFontCacheMutex); tc_elem = (tweencolor_t *) gdCacheGet(tc_cache, &tc_key); *pixel = tc_elem->tweencolor; + gdMutexUnlock(gdFontCacheMutex); } } } @@ -703,16 +715,6 @@ gdroundupdown (FT_F26Dot6 v1, int updown) return (!updown) ? (v1 < 0 ? ((v1 - 63) >> 6) : v1 >> 6) : (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) {