gdi32: Add sanity checks for brush hatch styles.
This commit is contained in:
parent
8bf48557ef
commit
ee89ce2982
|
@ -149,7 +149,15 @@ BOOL store_brush_pattern( LOGBRUSH *brush, struct brush_pattern *pattern )
|
||||||
{
|
{
|
||||||
case BS_SOLID:
|
case BS_SOLID:
|
||||||
case BS_HOLLOW:
|
case BS_HOLLOW:
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
case BS_HATCHED:
|
case BS_HATCHED:
|
||||||
|
if (brush->lbHatch > HS_DIAGCROSS)
|
||||||
|
{
|
||||||
|
if (brush->lbHatch >= HS_API_MAX) return FALSE;
|
||||||
|
brush->lbStyle = BS_SOLID;
|
||||||
|
brush->lbHatch = 0;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case BS_PATTERN8X8:
|
case BS_PATTERN8X8:
|
||||||
|
|
|
@ -79,6 +79,42 @@ static void test_solidbrush(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_hatch_brush(void)
|
||||||
|
{
|
||||||
|
int i, size;
|
||||||
|
HBRUSH brush;
|
||||||
|
LOGBRUSH lb;
|
||||||
|
|
||||||
|
for (i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
brush = CreateHatchBrush( i, RGB(12,34,56) );
|
||||||
|
if (i < HS_API_MAX)
|
||||||
|
{
|
||||||
|
ok( brush != 0, "%u: CreateHatchBrush failed err %u\n", i, GetLastError() );
|
||||||
|
size = GetObject( brush, sizeof(lb), &lb );
|
||||||
|
ok( size == sizeof(lb), "wrong size %u\n", size );
|
||||||
|
ok( lb.lbColor == RGB(12,34,56), "wrong color %08x\n", lb.lbColor );
|
||||||
|
if (i <= HS_DIAGCROSS)
|
||||||
|
{
|
||||||
|
ok( lb.lbStyle == BS_HATCHED, "wrong style %u\n", lb.lbStyle );
|
||||||
|
ok( lb.lbHatch == i, "wrong hatch %lu/%u\n", lb.lbHatch, i );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok( lb.lbStyle == BS_SOLID, "wrong style %u\n", lb.lbStyle );
|
||||||
|
ok( lb.lbHatch == 0, "wrong hatch %lu\n", lb.lbHatch );
|
||||||
|
}
|
||||||
|
DeleteObject( brush );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok( !brush, "%u: CreateHatchBrush succeeded\n", i );
|
||||||
|
ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void test_pattern_brush(void)
|
static void test_pattern_brush(void)
|
||||||
{
|
{
|
||||||
char buffer[sizeof(BITMAPINFOHEADER) + 2 * sizeof(RGBQUAD) + 32 * 32 / 8];
|
char buffer[sizeof(BITMAPINFOHEADER) + 2 * sizeof(RGBQUAD) + 32 * 32 / 8];
|
||||||
|
@ -310,6 +346,7 @@ static void test_palette_brush(void)
|
||||||
START_TEST(brush)
|
START_TEST(brush)
|
||||||
{
|
{
|
||||||
test_solidbrush();
|
test_solidbrush();
|
||||||
|
test_hatch_brush();
|
||||||
test_pattern_brush();
|
test_pattern_brush();
|
||||||
test_palette_brush();
|
test_palette_brush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,6 +526,7 @@ typedef LOGBRUSH PATTERN, *PPATTERN, *LPPATTERN;
|
||||||
#define HS_BDIAGONAL 3
|
#define HS_BDIAGONAL 3
|
||||||
#define HS_CROSS 4
|
#define HS_CROSS 4
|
||||||
#define HS_DIAGCROSS 5
|
#define HS_DIAGCROSS 5
|
||||||
|
#define HS_API_MAX 12
|
||||||
|
|
||||||
/* Fonts */
|
/* Fonts */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue