Skip to content

Commit

Permalink
Issue #179: fixed input/output buffer size.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-richard committed Sep 6, 2017
1 parent a370654 commit e14fd4f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/vmime/charsetConverter_win.cpp
Expand Up @@ -110,7 +110,10 @@ void charsetConverter_win::convert(const string& in, string& out, status* st)
} }
else 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); unicodeBuffer.resize(bufferSize);


DWORD flags = 0; DWORD flags = 0;
Expand Down Expand Up @@ -143,7 +146,9 @@ void charsetConverter_win::convert(const string& in, string& out, status* st)
} }
else 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; std::vector <char> buffer;
buffer.resize(bufferSize); buffer.resize(bufferSize);
Expand Down

0 comments on commit e14fd4f

Please sign in to comment.