diff options
author | Vincent Richard <[email protected]> | 2017-09-06 18:59:10 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2017-09-06 18:59:10 +0000 |
commit | e14fd4f2c9c3c9b368b1357cb642008e15b1d05c (patch) | |
tree | cf8288c66760a5ed342632cdf869fbf44052108e | |
parent | Merge pull request #178 from Aulddays/master (diff) | |
download | vmime-e14fd4f2c9c3c9b368b1357cb642008e15b1d05c.tar.gz vmime-e14fd4f2c9c3c9b368b1357cb642008e15b1d05c.zip |
Issue #179: fixed input/output buffer size.
-rw-r--r-- | src/vmime/charsetConverter_win.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/vmime/charsetConverter_win.cpp b/src/vmime/charsetConverter_win.cpp index d4a21a46..2c65f5fd 100644 --- a/src/vmime/charsetConverter_win.cpp +++ b/src/vmime/charsetConverter_win.cpp @@ -110,7 +110,10 @@ void charsetConverter_win::convert(const string& in, string& out, status* st) } else { - const size_t bufferSize = in.length() * 2; // in wide characters + const size_t bufferSize = MultiByteToWideChar + (sourceCodePage, 0, in.c_str(), static_cast <int>(in.length()), + NULL, 0) * sizeof(WCHAR); // in wide characters + unicodeBuffer.resize(bufferSize); DWORD flags = 0; @@ -143,7 +146,9 @@ void charsetConverter_win::convert(const string& in, string& out, status* st) } else { - const size_t bufferSize = unicodeLen * 6; // in multibyte characters + const size_t bufferSize = WideCharToMultiByte + (destCodePage, 0, unicodePtr, static_cast <int>(unicodeLen), + NULL, 0, 0, NULL); // in multibyte characters std::vector <char> buffer; buffer.resize(bufferSize); |