diff options
author | Sara Golemon <pollita@php.net> | 2014-08-19 12:46:53 -0700 |
---|---|---|
committer | Sara Golemon <pollita@php.net> | 2014-08-19 13:16:44 -0700 |
commit | cbe1597b747474388912c91018b0e12275784720 (patch) | |
tree | 666128438228e1aebd7cb70aba1961049f5d1f7b /ext/gd/libgd | |
parent | 5a7039035ce22a68130af2309ff002a611976c87 (diff) | |
download | php-git-cbe1597b747474388912c91018b0e12275784720.tar.gz |
Switch use of strtok() to gd_strtok_r()
strtok() is not thread safe, so this will potentially break in
very bad ways if used in ZTS mode.
I'm not sure why gd_strtok_r() exists since it seems to do the
same thing as strtok_r(), but I'll assume it's a portability
decision and do as the Romans do.
Diffstat (limited to 'ext/gd/libgd')
-rw-r--r-- | ext/gd/libgd/gdft.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index ac2bf344ff..884a4148fe 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -370,9 +370,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); @@ -388,7 +389,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 |