gdi32: Avoid an integer overflow in GetCharABCWidthsA.

This commit is contained in:
Akihiro Sagawa 2011-01-16 23:00:21 +09:00 committed by Alexandre Julliard
parent 62b5963507
commit d4924bf9a1
1 changed files with 3 additions and 3 deletions

View File

@ -2296,16 +2296,16 @@ BOOL WINAPI GetAspectRatioFilterEx( HDC hdc, LPSIZE pAspectRatio )
BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar, BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
LPABC abc ) LPABC abc )
{ {
INT i, wlen; INT i, wlen, count = (INT)(lastChar - firstChar + 1);
UINT c; UINT c;
LPSTR str; LPSTR str;
LPWSTR wstr; LPWSTR wstr;
BOOL ret = TRUE; BOOL ret = TRUE;
if (lastChar < firstChar) if (count <= 0)
return FALSE; return FALSE;
str = HeapAlloc(GetProcessHeap(), 0, (lastChar - firstChar + 1) * 2 + 1); str = HeapAlloc(GetProcessHeap(), 0, count * 2 + 1);
if (str == NULL) if (str == NULL)
return FALSE; return FALSE;