Avoid trouble in WM_GETTEXT if specified length is larger than the

buffer (found by Carl Sopchak).
This commit is contained in:
Alexandre Julliard 2002-08-15 23:28:45 +00:00
parent ebd110bc6a
commit 331bf3d77c
1 changed files with 3 additions and 4 deletions

View File

@ -3962,15 +3962,14 @@ static INT EDIT_WM_GetText(EDITSTATE *es, INT count, LPARAM lParam, BOOL unicode
if(unicode)
{
LPWSTR textW = (LPWSTR)lParam;
strncpyW(textW, es->text, count);
textW[count - 1] = 0; /* ensure 0 termination */
lstrcpynW(textW, es->text, count);
return strlenW(textW);
}
else
{
LPSTR textA = (LPSTR)lParam;
WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, count, NULL, NULL);
textA[count - 1] = 0; /* ensure 0 termination */
if (!WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, count, NULL, NULL))
textA[count - 1] = 0; /* ensure 0 termination */
return strlen(textA);
}
}