Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
Win: Revise string zero termination
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Rozman <[email protected]>
  • Loading branch information
rozmansi committed Jan 6, 2024
1 parent 9f5a68e commit 19e2dbb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/WinStd/Win.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCSTR pszName, _Out_
} else if (lResult == ERROR_MORE_DATA) {
if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
// The value is REG_SZ or REG_MULTI_SZ. Read it now.
sValue.resize(dwSize / sizeof(CHAR) - 1);
sValue.resize(dwSize / sizeof(CHAR));
if ((lResult = ::RegQueryValueExA(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(&sValue[0]), &dwSize)) == ERROR_SUCCESS) {
dwSize /= sizeof(CHAR);
sValue.resize(dwSize && sValue[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
Expand Down Expand Up @@ -503,7 +503,7 @@ static LSTATUS RegQueryStringValue(_In_ HKEY hReg, _In_z_ LPCWSTR pszName, _Out_
} else if (lResult == ERROR_MORE_DATA) {
if (dwType == REG_SZ || dwType == REG_MULTI_SZ) {
// The value is REG_SZ or REG_MULTI_SZ. Read it now.
sValue.resize(dwSize / sizeof(WCHAR) - 1);
sValue.resize(dwSize / sizeof(WCHAR));
if ((lResult = ::RegQueryValueExW(hReg, pszName, NULL, NULL, reinterpret_cast<LPBYTE>(&sValue[0]), &dwSize)) == ERROR_SUCCESS) {
dwSize /= sizeof(WCHAR);
sValue.resize(dwSize && sValue[dwSize - 1] == 0 ? dwSize - 1 : dwSize);
Expand Down Expand Up @@ -682,7 +682,7 @@ static _Success_(return > 0) int NormalizeString(_In_ NORM_FORM NormForm, _In_ c
for (int i = 10; i--;) {
// Allocate buffer. Then convert again.
cch = -cch;
sDstString.resize(cch - 1);
sDstString.resize(cch);
cch = ::NormalizeString(NormForm, sSrcString.c_str(), (int)sSrcString.length(), &sDstString[0], cch);
if (cch > 0)
break;
Expand Down

0 comments on commit 19e2dbb

Please sign in to comment.