diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-04-13 23:27:49 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-03-08 21:58:16 +0100 |
commit | b1f231452bdd4cffe87f3a41b31d8838da05badf (patch) | |
tree | 30c57cbc6c2a12560b53afa9dcda862f6a35eefc /src/common/Utilities/Util.cpp | |
parent | 8897151ffb9b2112ddb3edad1cd86f4ddab6117c (diff) |
Core/Console: Fix uninitialized variable
(cherry picked from commit 677952fbc59676b549337f9f7eb5c7e7abb1135e)
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 a595f654ec7..42cab23d9d4 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 @@ -790,9 +790,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; @@ -815,7 +815,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 |