fontCache race condition causes crash in gdImageStringFTEx()
Issue #119
new
Function gdImageStringFTEx(). fontCache isn't protected with gdFontCacheMutex:
/***** initialize font library and font cache on first call ******/ 893 if (!fontCache)
Thus few gdFontCacheSetup() can be invoked simultaneously.
Function gdFontCacheSetup(). Again, only initialization of gdFontCacheMutex and no protection for the following actions:
if (FT_Init_FreeType (&library)) ... fontCache = gdCacheCreate (FONTCACHESIZE, fontTest, fontFetch, fontRelease); if (!fontCache) {
I suppose gdFontCacheMutex should be statically initialized with some kind of PTHREAD_MUTEX_INITIALIZER (perhaps inside or even instead of gdMutexDeclare()).
Also fontCache should be protected with above mutex.