com php-src: Switch use of strtok() to gd_strtok_r(): NEWS ext/gd/libgd/gdft.c

From: Date: Tue, 19 Aug 2014 20:16:44 +0000
Subject: com php-src: Switch use of strtok() to gd_strtok_r(): NEWS ext/gd/libgd/gdft.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-80621@lists.php.net to get a copy of this message
Commit: cbe1597b747474388912c91018b0e12275784720 Author: Sara Golemon <pollita@php.net> Tue, 19 Aug 2014 12:46:53 -0700 Parents: 5a7039035ce22a68130af2309ff002a611976c87 Branches: PHP-5.4 PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cbe1597b747474388912c91018b0e12275784720 Log: 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. Changed paths: M NEWS M ext/gd/libgd/gdft.c Diff: diff --git a/NEWS b/NEWS index f515bbe..5df4032 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,9 @@ PHP NEWS - Date: . Fixed bug #66091 (memory leaks in DateTime constructor). (Tjerk). +- GD + . Made fontFetch's path parser thread-safe. (Sara). + ?? ??? 2014, PHP 5.4.32 - COM: diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index ac2bf34..884a414 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

« previous php.cvs (#80621) next »