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

Commit

Permalink
windows: use _snwprintf(), not swprintf()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bnoordhuis committed Nov 8, 2013
1 parent 24bfef2 commit c6ecf97
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c6ecf97

Please sign in to comment.