diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/gd/libgd/gdft.c | 6 |
2 files changed, 7 insertions, 2 deletions
@@ -25,4 +25,7 @@ PHP NEWS - XSL: . Fixed bug #64776 (The XSLT extension is not thread safe). (Mike) +- GD: + . Made fontFetch's path parser thread-safe. (Sara) + <<< NOTE: Insert NEWS from last stable release here prior to actual release! >>> diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index 4979e1511f..4148cf47bb 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -390,9 +390,10 @@ static void *fontFetch (char **error, void *key) fontlist = gdEstrdup(a->fontlist); /* - * Must use gd_strtok_r else pointer corrupted by strtok in nested loop. + * Must use gd_strtok_r becasuse strtok() isn't thread safe */ for (name = gd_strtok_r (fontlist, LISTSEPARATOR, &strtok_ptr); name; name = gd_strtok_r (0, LISTSEPARATOR, &strtok_ptr)) { + char *strtok_ptr_path; /* make a fresh copy each time - strtok corrupts it. */ path = gdEstrdup (fontsearchpath); @@ -408,7 +409,8 @@ static void *fontFetch (char **error, void *key) break; } } - for (dir = strtok (path, PATHSEPARATOR); dir; dir = strtok (0, PATHSEPARATOR)) { + for (dir = gd_strtok_r (path, PATHSEPARATOR, &strtok_ptr_path); dir; + dir = gd_strtok_r (0, PATHSEPARATOR, &strtok_ptr_path)) { if (!strcmp(dir, ".")) { TSRMLS_FETCH(); #if HAVE_GETCWD |