Skip to content

Commit 1ec93f8

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: Switch use of strtok() to gd_strtok_r()
2 parents 14439b7 + a309dda commit 1ec93f8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ PHP NEWS
2525
- XSL:
2626
. Fixed bug #64776 (The XSLT extension is not thread safe). (Mike)
2727

28+
- GD:
29+
. Made fontFetch's path parser thread-safe. (Sara)
30+
2831
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

ext/gd/libgd/gdft.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,10 @@ static void *fontFetch (char **error, void *key)
390390
fontlist = gdEstrdup(a->fontlist);
391391

392392
/*
393-
* Must use gd_strtok_r else pointer corrupted by strtok in nested loop.
393+
* Must use gd_strtok_r becasuse strtok() isn't thread safe
394394
*/
395395
for (name = gd_strtok_r (fontlist, LISTSEPARATOR, &strtok_ptr); name; name = gd_strtok_r (0, LISTSEPARATOR, &strtok_ptr)) {
396+
char *strtok_ptr_path;
396397
/* make a fresh copy each time - strtok corrupts it. */
397398
path = gdEstrdup (fontsearchpath);
398399

@@ -408,7 +409,8 @@ static void *fontFetch (char **error, void *key)
408409
break;
409410
}
410411
}
411-
for (dir = strtok (path, PATHSEPARATOR); dir; dir = strtok (0, PATHSEPARATOR)) {
412+
for (dir = gd_strtok_r (path, PATHSEPARATOR, &strtok_ptr_path); dir;
413+
dir = gd_strtok_r (0, PATHSEPARATOR, &strtok_ptr_path)) {
412414
if (!strcmp(dir, ".")) {
413415
TSRMLS_FETCH();
414416
#if HAVE_GETCWD

0 commit comments

Comments
 (0)