From 41da75d59f79875596bca8827c1331efa6131a76 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 26 Nov 2006 17:03:15 +0000 Subject: [PATCH] MFB: Fixed bug #39623 (thread safety fixes on *nix for mime_magic extenion). --- ext/mime_magic/mime_magic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/mime_magic/mime_magic.c b/ext/mime_magic/mime_magic.c index 958501cc24..3bd1b21796 100644 --- a/ext/mime_magic/mime_magic.c +++ b/ext/mime_magic/mime_magic.c @@ -1388,6 +1388,7 @@ static int ascmagic(unsigned char *buf, int nbytes) char *token; register struct names *p; int small_nbytes; + char *strtok_buf = NULL; /* these are easy, do them first */ @@ -1420,8 +1421,7 @@ static int ascmagic(unsigned char *buf, int nbytes) s = (unsigned char *) memcpy(nbuf, buf, small_nbytes); s[small_nbytes] = '\0'; has_escapes = (memchr(s, '\033', small_nbytes) != NULL); - /* XXX: not multithread safe */ - while ((token = strtok((char *) s, " \t\n\r\f")) != NULL) { + while ((token = php_strtok_r((char *) s, " \t\n\r\f", &strtok_buf)) != NULL) { s = NULL; /* make strtok() keep on tokin' */ for (p = names; p < names + NNAMES; p++) { if (STREQ(p->name, token)) { -- 2.50.1