Skip to content
This repository was archived by the owner on May 4, 2018. It is now read-only.

Commit c6ecf97

Browse files
committed
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.
1 parent 24bfef2 commit c6ecf97

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/win/fs.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,7 @@ void fs__readdir(uv_fs_t* req) {
738738
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
739739
}
740740

741-
#ifdef _CRT_NON_CONFORMING_SWPRINTFS
742-
swprintf(path2, fmt, pathw);
743-
#else
744-
swprintf(path2, len + 3, fmt, pathw);
745-
#endif
741+
_snwprintf(path2, len + 3, fmt, pathw);
746742
dir = FindFirstFileW(path2, &ent);
747743
free(path2);
748744

0 commit comments

Comments
 (0)