[*] Bug fix: NT registry read function conflated array length with count

[*] Locale convert wchar -> utf count was not respected under non-nt targets
This commit is contained in:
Reece Wilson 2022-05-26 15:02:23 +01:00
parent dc59e59e2a
commit e665714341
2 changed files with 6 additions and 3 deletions

View File

@ -60,7 +60,7 @@ namespace Aurora::Locale
WideCharToMultiByte(CP_UTF8, 0, in, length, ret.data(), ret.size(), NULL, NULL);
return ret;
#elif !defined(AU_NO_CPPLOCALE)
return gUtf8Conv.to_bytes(std::wstring(in, wcslen(in)));
return gUtf8Conv.to_bytes(std::wstring(in, wcsnlen(in, length)));
#else
SysPushErrorUnimplemented("ConvertFromWChar");
return {};

View File

@ -43,7 +43,7 @@ namespace Aurora::SWInfo
std::wstring in;
if (!AuTryResize(in, dwBufferSize))
if (!AuTryResize(in, dwBufferSize / sizeof(wchar_t)))
{
SysPushErrorMem();
return false;
@ -55,7 +55,10 @@ namespace Aurora::SWInfo
return false;
}
strValue = Locale::ConvertFromWChar(in.data(), in.size());
auto c = dwBufferSize / sizeof(wchar_t);
if (c) c--;
strValue = Locale::ConvertFromWChar(in.data(), c);
return strValue.size();
}