Win: Trim trailing zeros in LoadStringW

When resources are compiled with /n (default), all strings are zero
terminated and LoadStringW returns number of characters including this
terminator.

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2025-01-30 13:43:26 +01:00
parent bbe3da0303
commit d3f8439118

View File

@ -726,6 +726,7 @@ static _Success_(return != 0) int LoadStringW(_In_opt_ HINSTANCE hInstance, _In_
LPCWSTR pszStr; LPCWSTR pszStr;
int i = LoadStringW(hInstance, uID, reinterpret_cast<LPWSTR>(&pszStr), 0); int i = LoadStringW(hInstance, uID, reinterpret_cast<LPWSTR>(&pszStr), 0);
if (i) { if (i) {
i = wcsnlen_s(pszStr, i);
sBuffer.assign(pszStr, i); sBuffer.assign(pszStr, i);
return i; return i;
} else } else