diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index c64831007ea..cf32988f2b3 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -557,7 +557,7 @@ unsigned char* _mbsrchr(const unsigned char* s, unsigned int x) */ unsigned char* _mbstok(unsigned char *str, const unsigned char *delim) { - static char *next = NULL; + MSVCRT_thread_data *data = msvcrt_get_thread_data(); char *ret; if(MSVCRT___mb_cur_max > 1) @@ -565,7 +565,7 @@ unsigned char* _mbstok(unsigned char *str, const unsigned char *delim) unsigned int c; if (!str) - if (!(str = next)) return NULL; + if (!(str = data->mbstok_next)) return NULL; while ((c = _mbsnextc(str)) && _mbschr(delim, c)) { str += c > 255 ? 2 : 1; @@ -579,7 +579,7 @@ unsigned char* _mbstok(unsigned char *str, const unsigned char *delim) *str++ = 0; if (c > 255) *str++ = 0; } - next = str; + data->mbstok_next = str; return ret; } return strtok(str, delim); /* ASCII CP */ diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index c04ec9d6194..7985bb85327 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -38,6 +38,7 @@ typedef struct __MSVCRT_thread_data { int errno; unsigned long doserrno; + char *mbstok_next; /* next ptr for mbstok() */ terminate_function terminate_handler; unexpected_function unexpected_handler; _se_translator_function se_translator;