Avoid trouble in WM_GETTEXT if specified length is larger than the
buffer (found by Carl Sopchak).
This commit is contained in:
parent
ebd110bc6a
commit
331bf3d77c
@ -3962,14 +3962,13 @@ static INT EDIT_WM_GetText(EDITSTATE *es, INT count, LPARAM lParam, BOOL unicode
|
|||||||
if(unicode)
|
if(unicode)
|
||||||
{
|
{
|
||||||
LPWSTR textW = (LPWSTR)lParam;
|
LPWSTR textW = (LPWSTR)lParam;
|
||||||
strncpyW(textW, es->text, count);
|
lstrcpynW(textW, es->text, count);
|
||||||
textW[count - 1] = 0; /* ensure 0 termination */
|
|
||||||
return strlenW(textW);
|
return strlenW(textW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LPSTR textA = (LPSTR)lParam;
|
LPSTR textA = (LPSTR)lParam;
|
||||||
WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, count, NULL, NULL);
|
if (!WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, count, NULL, NULL))
|
||||||
textA[count - 1] = 0; /* ensure 0 termination */
|
textA[count - 1] = 0; /* ensure 0 termination */
|
||||||
return strlen(textA);
|
return strlen(textA);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user