gdi32: Reject invalid character range in GetCharABCWidthsA.
This commit is contained in:
parent
c706ecea82
commit
c117d45cb3
|
@ -1553,7 +1553,7 @@ UINT WINAPI GetOutlineTextMetricsW(
|
|||
return ret;
|
||||
}
|
||||
|
||||
static LPSTR FONT_GetCharsByRangeA(UINT firstChar, UINT lastChar, PINT pByteLen)
|
||||
static LPSTR FONT_GetCharsByRangeA(HDC hdc, UINT firstChar, UINT lastChar, PINT pByteLen)
|
||||
{
|
||||
INT i, count = lastChar - firstChar + 1;
|
||||
UINT c;
|
||||
|
@ -1562,6 +1562,22 @@ static LPSTR FONT_GetCharsByRangeA(UINT firstChar, UINT lastChar, PINT pByteLen)
|
|||
if (count <= 0)
|
||||
return NULL;
|
||||
|
||||
switch (GdiGetCodePage(hdc))
|
||||
{
|
||||
case 932:
|
||||
case 936:
|
||||
case 949:
|
||||
case 950:
|
||||
case 1361:
|
||||
if (lastChar > 0xffff)
|
||||
return NULL;
|
||||
break;
|
||||
default:
|
||||
if (lastChar > 0xff)
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
str = HeapAlloc(GetProcessHeap(), 0, count * 2 + 1);
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
|
@ -1620,7 +1636,7 @@ BOOL WINAPI GetCharWidth32A( HDC hdc, UINT firstChar, UINT lastChar,
|
|||
LPWSTR wstr;
|
||||
BOOL ret = TRUE;
|
||||
|
||||
str = FONT_GetCharsByRangeA(firstChar, lastChar, &i);
|
||||
str = FONT_GetCharsByRangeA(hdc, firstChar, lastChar, &i);
|
||||
if(str == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -2324,7 +2340,7 @@ BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
|
|||
LPWSTR wstr;
|
||||
BOOL ret = TRUE;
|
||||
|
||||
str = FONT_GetCharsByRangeA(firstChar, lastChar, &i);
|
||||
str = FONT_GetCharsByRangeA(hdc, firstChar, lastChar, &i);
|
||||
if (str == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -3010,7 +3026,7 @@ BOOL WINAPI GetCharABCWidthsFloatA( HDC hdc, UINT first, UINT last, LPABCFLOAT a
|
|||
LPWSTR wstr;
|
||||
BOOL ret = TRUE;
|
||||
|
||||
str = FONT_GetCharsByRangeA(first, last, &i);
|
||||
str = FONT_GetCharsByRangeA(hdc, first, last, &i);
|
||||
if (str == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -1011,39 +1011,30 @@ static void test_GetCharABCWidths(void)
|
|||
ok(ret == c[i].r[0], "GetCharABCWidthsA should have %s\n", c[i].r[0] ? "succeeded" : "failed");
|
||||
|
||||
ret = pGetCharABCWidthsA(hdc, 0x100, 0x100, abc);
|
||||
todo_wine
|
||||
ok(ret == c[i].r[1], "GetCharABCWidthsA should have %s\n", c[i].r[1] ? "succeeded" : "failed");
|
||||
|
||||
ret = pGetCharABCWidthsA(hdc, 0xff, 0x100, a);
|
||||
todo_wine
|
||||
ok(ret == c[i].r[2], "GetCharABCWidthsA should have %s\n", c[i].r[2] ? "succeeded" : "failed");
|
||||
|
||||
ret = pGetCharABCWidthsA(hdc, 0xffff, 0xffff, abc);
|
||||
todo_wine
|
||||
ok(ret == c[i].r[3], "GetCharABCWidthsA should have %s\n", c[i].r[3] ? "succeeded" : "failed");
|
||||
|
||||
ret = pGetCharABCWidthsA(hdc, 0x10000, 0x10000, abc);
|
||||
todo_wine
|
||||
ok(ret == c[i].r[4], "GetCharABCWidthsA should have %s\n", c[i].r[4] ? "succeeded" : "failed");
|
||||
|
||||
ret = pGetCharABCWidthsA(hdc, 0xffff, 0x10000, a);
|
||||
todo_wine
|
||||
ok(ret == c[i].r[5], "GetCharABCWidthsA should have %s\n", c[i].r[5] ? "succeeded" : "failed");
|
||||
|
||||
ret = pGetCharABCWidthsA(hdc, 0xffffff, 0xffffff, abc);
|
||||
todo_wine
|
||||
ok(ret == c[i].r[6], "GetCharABCWidthsA should have %s\n", c[i].r[6] ? "succeeded" : "failed");
|
||||
|
||||
ret = pGetCharABCWidthsA(hdc, 0x1000000, 0x1000000, abc);
|
||||
todo_wine
|
||||
ok(ret == c[i].r[7], "GetCharABCWidthsA should have %s\n", c[i].r[7] ? "succeeded" : "failed");
|
||||
|
||||
ret = pGetCharABCWidthsA(hdc, 0xffffff, 0x1000000, a);
|
||||
todo_wine
|
||||
ok(ret == c[i].r[8], "GetCharABCWidthsA should have %s\n", c[i].r[8] ? "succeeded" : "failed");
|
||||
|
||||
ret = pGetCharABCWidthsA(hdc, 0xffffffff, 0xffffffff, abc);
|
||||
todo_wine
|
||||
ok(ret == c[i].r[9], "GetCharABCWidthsA should have %s\n", c[i].r[9] ? "succeeded" : "failed");
|
||||
|
||||
hfont = SelectObject(hdc, hfont);
|
||||
|
|
Loading…
Reference in New Issue