windows: use _snwprintf(), not swprintf()

Drop the _CRT_NON_CONFORMING_SWPRINTFS hack and just use _snwprintf().

It's a long and complicated story but the gist of it is that the MS CRT
had a swprintf() function before ISO C did, with a different function
prototype to boot: the ISO C one takes a |size| argument, the MS one
does not.

The function prototype that's exported by mingw and mingw-w64 depends
on the mingw version and the _CRT_NON_CONFORMING_SWPRINTFS define.
If they don't match up, you get the wrong prototype and things will
crash at run-time.

Reduce the phase space by sidestepping the whole issue: drop swprintf()
altogether and use _snwprintf() from now on.

Fixes #990.
This commit is contained in:
Ben Noordhuis 2013-11-08 12:22:37 +01:00
parent 24bfef2ef4
commit c6ecf97aaf

View File

@ -738,11 +738,7 @@ void fs__readdir(uv_fs_t* req) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
}
#ifdef _CRT_NON_CONFORMING_SWPRINTFS
swprintf(path2, fmt, pathw);
#else
swprintf(path2, len + 3, fmt, pathw);
#endif
_snwprintf(path2, len + 3, fmt, pathw);
dir = FindFirstFileW(path2, &ent);
free(path2);