File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,8 +67,20 @@ EBRUSHOBJ_vInit(EBRUSHOBJ *pebo,
6767 pebo -> psoMask = NULL ;
6868
6969 /* Initialize 1 bpp fore and back colors */
70- pebo -> crCurrentBack = crBackgroundClr ;
71- pebo -> crCurrentText = crForegroundClr ;
70+ /*
71+ * COLORREF uses only 24 bits (0x00BBGGRR).
72+ *
73+ * Note that 0xFFFFFFFF is CLR_INVALID in GDI, but we have also observed
74+ * some code paths feeding in ARGB values (e.g. 0xFFFFFFFF for opaque white).
75+ * We normalize to sane 24-bit defaults if we get CLR_INVALID, and otherwise
76+ * mask away any high byte to avoid sentinel collisions in drivers/ENG.
77+ */
78+
79+ pebo -> crCurrentBack = (crBackgroundClr == CLR_INVALID ) ?
80+ 0x00FFFFFF : (crBackgroundClr & 0x00FFFFFF );
81+
82+ pebo -> crCurrentText = (crForegroundClr == CLR_INVALID ) ?
83+ 0x00000000 : (crForegroundClr & 0x00FFFFFF );
7284
7385 pebo -> psurfTrg = psurf ;
7486 /* We are initializing for a new memory DC */
@@ -103,7 +115,7 @@ EBRUSHOBJ_vInit(EBRUSHOBJ *pebo,
103115
104116 /* Use foreground color of hatch brushes */
105117 if (pbrush -> flAttrs & BR_IS_HATCH )
106- pebo -> crCurrentText = pbrush -> BrushAttr .lbColor ;
118+ pebo -> crCurrentText = pbrush -> BrushAttr .lbColor & 0x00FFFFFF ;
107119 }
108120}
109121
You can’t perform that action at this time.
0 commit comments