diff options
author | Nicolas Williams <nico@cryptonector.com> | 2016-01-15 11:58:41 -0600 |
---|---|---|
committer | Nicolas Williams <nico@cryptonector.com> | 2016-01-15 11:58:41 -0600 |
commit | f217fa26ae913da21686b1d5b381e07f69d91675 (patch) | |
tree | 56681a950617ac799e05d5331f081ea5a13a19c8 | |
parent | 8f6f28c8d3fd6fb85439add3e812edeb5a887999 (diff) |
MultiByteToWideChar() usage bug (fix #1072)
-rw-r--r-- | src/util.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -48,11 +48,11 @@ void *alloca (size_t); #ifdef WIN32 FILE *fopen(const char *fname, const char *mode) { size_t sz = sizeof(wchar_t) * MultiByteToWideChar(CP_UTF8, 0, fname, -1, NULL, 0); - wchar_t *wfname = alloca(sz); + wchar_t *wfname = alloca(sz + 2); // +2 is not needed, but just in case MultiByteToWideChar(CP_UTF8, 0, fname, -1, wfname, sz); - sz = MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0); - wchar_t *wmode = alloca(sz); + sz = sizeof(wchar_t) * MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0); + wchar_t *wmode = alloca(sz); // +2 is not needed, but just in case MultiByteToWideChar(CP_UTF8, 0, mode, -1, wmode, sz); return _wfopen(wfname, wmode); } |