Skip to content
Snippets Groups Projects
Commit c23e388b authored by Brad King's avatar Brad King
Browse files

ConsoleBuf: Avoid signed/unsigned comparison

Use `size_t` for lengths in `decodeInputBuffer`.
parent fe1f22ce
No related branches found
No related tags found
No related merge requests found
...@@ -338,7 +338,7 @@ private: ...@@ -338,7 +338,7 @@ private:
} }
bool decodeInputBuffer(const std::string buffer, std::wstring& wbuffer) bool decodeInputBuffer(const std::string buffer, std::wstring& wbuffer)
{ {
int length = int(buffer.length()); size_t length = buffer.length();
if (length == 0) { if (length == 0) {
wbuffer = std::wstring(); wbuffer = std::wstring();
return true; return true;
...@@ -353,11 +353,12 @@ private: ...@@ -353,11 +353,12 @@ private:
data += BOMsize; data += BOMsize;
length -= BOMsize; length -= BOMsize;
} }
const int wlength = const size_t wlength = static_cast<size_t>(MultiByteToWideChar(
MultiByteToWideChar(actualCodepage, 0, data, length, NULL, 0); actualCodepage, 0, data, static_cast<int>(length), NULL, 0));
wchar_t* wbuf = new wchar_t[wlength]; wchar_t* wbuf = new wchar_t[wlength];
const bool success = const bool success =
MultiByteToWideChar(actualCodepage, 0, data, length, wbuf, wlength) > 0 MultiByteToWideChar(actualCodepage, 0, data, static_cast<int>(length),
wbuf, static_cast<int>(wlength)) > 0
? true ? true
: false; : false;
wbuffer = std::wstring(wbuf, wlength); wbuffer = std::wstring(wbuf, wlength);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment