[IMM32] Use UNICODE_NULL for null characters

CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-10-20 12:29:29 +09:00
parent 378d0e814c
commit f9b2b1a6cd
2 changed files with 6 additions and 6 deletions

View file

@ -69,7 +69,7 @@ BOOL APIENTRY Imm32InquireIme(PIMEDPI pImeDpi)
return FALSE;
}
szUIClass[_countof(szUIClass) - 1] = 0;
szUIClass[_countof(szUIClass) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
if (pImeInfo->dwPrivateDataSize == 0)
pImeInfo->dwPrivateDataSize = sizeof(DWORD);
@ -1224,7 +1224,7 @@ LRESULT WINAPI ImmEscapeA(HKL hKL, HIMC hIMC, UINT uSubFunc, LPVOID lpData)
ret = ImeDpi_Escape(pImeDpi, hIMC, uSubFunc, szW, hKL);
if (ret)
{
szW[_countof(szW) - 1] = 0;
szW[_countof(szW) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
WideCharToMultiByte(pImeDpi->uCodePage, 0, szW, -1,
lpData, MAX_IMM_FILENAME, NULL, NULL);
((LPSTR)lpData)[MAX_IMM_FILENAME - 1] = 0;
@ -1235,7 +1235,7 @@ LRESULT WINAPI ImmEscapeA(HKL hKL, HIMC hIMC, UINT uSubFunc, LPVOID lpData)
case IME_ESC_HANJA_MODE:
MultiByteToWideChar(pImeDpi->uCodePage, MB_PRECOMPOSED,
lpData, -1, szW, _countof(szW));
szW[_countof(szW) - 1] = 0;
szW[_countof(szW) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
ret = ImeDpi_Escape(pImeDpi, hIMC, uSubFunc, szW, hKL);
break;
@ -1304,7 +1304,7 @@ LRESULT WINAPI ImmEscapeW(HKL hKL, HIMC hIMC, UINT uSubFunc, LPVOID lpData)
szA[_countof(szA) - 1] = 0;
MultiByteToWideChar(pImeDpi->uCodePage, MB_PRECOMPOSED,
szA, -1, lpData, MAX_IMM_FILENAME);
((LPWSTR)lpData)[MAX_IMM_FILENAME - 1] = 0;
((LPWSTR)lpData)[MAX_IMM_FILENAME - 1] = UNICODE_NULL; /* Avoid buffer overrun */
}
break;

View file

@ -904,7 +904,7 @@ UINT APIENTRY Imm32GetImeLayout(PREG_IME pLayouts, UINT cLayouts)
szImeFileName[0] = 0;
cbData = sizeof(szImeFileName);
RegQueryValueExW(hkeyIME, L"Ime File", NULL, NULL, (LPBYTE)szImeFileName, &cbData);
szImeFileName[_countof(szImeFileName) - 1] = 0;
szImeFileName[_countof(szImeFileName) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
RegCloseKey(hkeyIME);
@ -997,7 +997,7 @@ BOOL APIENTRY Imm32WriteImeLayout(HKL hKL, LPCWSTR pchFilePart, LPCWSTR pszLayou
cbData = sizeof(szPreloadKey);
lError = RegQueryValueExW(hkeyPreload, szPreloadNumber, NULL, NULL,
(LPBYTE)szPreloadKey, &cbData);
szPreloadKey[_countof(szPreloadKey) - 1] = 0;
szPreloadKey[_countof(szPreloadKey) - 1] = UNICODE_NULL; /* Avoid buffer overrun */
if (lError != ERROR_SUCCESS || lstrcmpiW(szImeKey, szPreloadKey) == 0)
break; /* Found an empty room or the same key */