cvs: gd /libgd gdft.c
[email protected] ("Pierre-Alain Joye")
| Newsgroups | php.gd.cvs |
|---|---|
| Message-ID | <cvspajoye1172518258@cvsserver> |
pajoye Mon Feb 26 19:30:58 2007 UTC
Modified files:
/gd/libgd gdft.c
Log:
- MFB: #48, Race condition in gdImageStringFTEx (cache)
http://cvs.php.net/viewvc.cgi/gd/libgd/gdft.c?r1=1.30&r2=1.31&diff_format=u
Index: gd/libgd/gdft.c
diff -u gd/libgd/gdft.c:1.30 gd/libgd/gdft.c:1.31
--- gd/libgd/gdft.c:1.30 Thu Feb 1 11:01:26 2007
+++ gd/libgd/gdft.c Mon Feb 26 19:30:57 2007
@@ -217,6 +217,16 @@
return strcmp(en1->name, en2->name);
}
+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;
+static FT_Library library;
+
#define Tcl_UniChar int
#define TCL_UTF_MAX 3
static int
@@ -767,24 +777,16 @@
/* find antialised color */
tc_key.bgcolor = *pixel;
+ gdMutexLock(gdFontCacheMutex);
tc_elem = (tweencolor_t *) gdCacheGet (tc_cache, &tc_key);
*pixel = tc_elem->tweencolor;
+ gdMutexUnlock(gdFontCacheMutex);
}
}
}
return (char *) NULL;
}
-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;
-static FT_Library library;
-
BGD_DECLARE(void) gdFreeFontCache ()
{
gdFontCacheShutdown ();
@@ -794,11 +796,12 @@
{
if (fontCache)
{
- gdMutexShutdown (gdFontCacheMutex);
+ gdMutexLock(gdFontCacheMutex);
gdCacheDelete (fontCache);
- FT_Done_FreeType (library);
/* 2.0.16: Gustavo Scotti: make sure we don't free this twice */
fontCache = 0;
+ gdMutexShutdown (gdFontCacheMutex);
+ FT_Done_FreeType (library);
}
}