diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-04-13 23:27:49 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-04-13 23:27:49 +0200 |
commit | 677952fbc59676b549337f9f7eb5c7e7abb1135e (patch) | |
tree | 7dce1f9766e900111c1665e079436562775dbc9e /src/common/Utilities/Util.cpp | |
parent | 6a46817f5d0a9ec760cc16b0871b74c40033f69a (diff) |
Core/Console: Fix uninitialized variable
Diffstat (limited to 'src/common/Utilities/Util.cpp')
-rw-r--r-- | src/common/Utilities/Util.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index bf724629676..6fa4825f06b 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -442,7 +442,7 @@ bool WStrToUtf8(std::wstring_view wstr, std::string& utf8str) std::string utf8str2; utf8str2.resize(wstr.size()*4); // allocate for most long case - if (wstr.size()) + if (!wstr.empty()) { char* oend = utf8::utf16to8(wstr.begin(), wstr.end(), &utf8str2[0]); utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail @@ -605,9 +605,9 @@ bool ReadWinConsole(std::string& str, size_t size /*= 256*/) { wchar_t* commandbuf = new wchar_t[size + 1]; HANDLE hConsole = GetStdHandle(STD_INPUT_HANDLE); - DWORD read; + DWORD read = 0; - if (!ReadConsoleW(hConsole, commandbuf, size, &read, NULL)) + if (!ReadConsoleW(hConsole, commandbuf, size, &read, nullptr)) { delete[] commandbuf; return false; @@ -630,7 +630,7 @@ bool WriteWinConsole(std::string_view str, bool error /*= false*/) DWORD toWrite = wstr.size(); DWORD write; - return WriteConsoleW(hConsole, wstr.c_str(), wstr.size(), &write, NULL); + return WriteConsoleW(hConsole, wstr.c_str(), wstr.size(), &write, nullptr); } #endif |