1. libgd
  2. Untitled project
  3. gd-libgd
  4. Issues


Issue #119 new

fontCache race condition causes crash in gdImageStringFTEx()

Anonymous created an issue

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.

Comments (0)

  1. Log in to comment