Our printf and msg code uses wcrtomb, but on Windows wcrtomb is
#defined to wctomb, which is not thread-safe. The call sites
think they are getting wcrtomb, and are coded to be thread-safe.
The #define has a comment that wcrtomb is not available in
Windows, but sandbox builds seem to work just fine with the
#define removed, so let's try taking it out. The resulting
code will still not be completely thread-safe, wcrtomb is
vulnerable if another thread calls setlocale while it is
executing, but callers are supposed to using Unicode_Init,
not setlocale, so let's ignore that problem for now.
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
/*
- * Pretend to have wcsrtombs() and wcrtomb().
* Don't use typedef for mbstate_t because it's actually defined
- * in VS2003/VC7/include/wchar.h, but the functions don't exist.
- * I don't know why, nor do I care. -- edward
+ * in VS2003/VC7/include/wchar.h -- edward
*/
#ifdef _WIN32
#define mbstate_t int
-#define wcsrtombs(dest, srcp, n, state) wcstombs(dest, *(srcp), n)
-#define wcrtomb(dest, wc, state) wctomb(dest, wc)
#endif