gdi32: Improve AddFontMemResourceEx parameter validation.
This commit is contained in:
parent
1186e3caca
commit
ca96aed384
|
@ -3188,6 +3188,12 @@ HANDLE WINAPI AddFontMemResourceEx( PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD
|
||||||
HANDLE ret;
|
HANDLE ret;
|
||||||
DWORD num_fonts;
|
DWORD num_fonts;
|
||||||
|
|
||||||
|
if (!pbFont || !cbFont || !pcFonts)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ret = WineEngAddFontMemResourceEx(pbFont, cbFont, pdv, &num_fonts);
|
ret = WineEngAddFontMemResourceEx(pbFont, cbFont, pdv, &num_fonts);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3185,6 +3185,8 @@ static void test_AddFontMemResource(void)
|
||||||
void *font;
|
void *font;
|
||||||
DWORD font_size, num_fonts;
|
DWORD font_size, num_fonts;
|
||||||
HANDLE ret;
|
HANDLE ret;
|
||||||
|
DEVMODEA dmA;
|
||||||
|
BOOL is_winxp;
|
||||||
|
|
||||||
if (!pAddFontMemResourceEx || !pRemoveFontMemResourceEx)
|
if (!pAddFontMemResourceEx || !pRemoveFontMemResourceEx)
|
||||||
{
|
{
|
||||||
|
@ -3199,6 +3201,74 @@ static void test_AddFontMemResource(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_winxp = EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA) &&
|
||||||
|
(dmA.dmFields & DM_DISPLAYORIENTATION);
|
||||||
|
|
||||||
|
if (is_winxp)
|
||||||
|
{
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pAddFontMemResourceEx(NULL, 0, NULL, NULL);
|
||||||
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pAddFontMemResourceEx(NULL, 10, NULL, NULL);
|
||||||
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pAddFontMemResourceEx(NULL, 0, NULL, &num_fonts);
|
||||||
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pAddFontMemResourceEx(NULL, 10, NULL, &num_fonts);
|
||||||
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pAddFontMemResourceEx(font, 0, NULL, NULL);
|
||||||
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pAddFontMemResourceEx(font, 10, NULL, NULL);
|
||||||
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
|
||||||
|
num_fonts = 0xdeadbeef;
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pAddFontMemResourceEx(font, 0, NULL, &num_fonts);
|
||||||
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
ok(num_fonts == 0xdeadbeef, "number of loaded fonts should be 0xdeadbeef\n");
|
||||||
|
|
||||||
|
num_fonts = 0xdeadbeef;
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
ret = pAddFontMemResourceEx(font, 10, NULL, &num_fonts);
|
||||||
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == 0xdeadbeef,
|
||||||
|
"Expected GetLastError() to return 0xdeadbeef, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
ok(num_fonts == 0xdeadbeef, "number of loaded fonts should be 0xdeadbeef\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
win_skip("AddFontMemResourceEx invalid parameter tests are problematic on Win2k\n");
|
||||||
|
|
||||||
num_fonts = 0xdeadbeef;
|
num_fonts = 0xdeadbeef;
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pAddFontMemResourceEx(font, font_size, NULL, &num_fonts);
|
ret = pAddFontMemResourceEx(font, font_size, NULL, &num_fonts);
|
||||||
|
@ -3215,11 +3285,19 @@ static void test_AddFontMemResource(void)
|
||||||
font = load_font("sserife.fon", &font_size);
|
font = load_font("sserife.fon", &font_size);
|
||||||
ok(font != NULL, "Unable to locate and load font sserife.fon\n");
|
ok(font != NULL, "Unable to locate and load font sserife.fon\n");
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
ret = pAddFontMemResourceEx(font, font_size, NULL, (void *)0xdeadbeef);
|
ret = pAddFontMemResourceEx(font, font_size, NULL, (void *)0xdeadbeef);
|
||||||
ok(!ret, "AddFontMemResourceEx should fail\n");
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == 0xdeadbeef,
|
||||||
|
"Expected GetLastError() to return 0xdeadbeef, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
ret = pAddFontMemResourceEx(font, font_size, NULL, NULL);
|
ret = pAddFontMemResourceEx(font, font_size, NULL, NULL);
|
||||||
ok(!ret, "AddFontMemResourceEx should fail\n");
|
ok(!ret, "AddFontMemResourceEx should fail\n");
|
||||||
|
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
||||||
|
"Expected GetLastError() to return ERROR_INVALID_PARAMETER, got %u\n",
|
||||||
|
GetLastError());
|
||||||
|
|
||||||
free_font(font);
|
free_font(font);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue