gdi32: Patch review request

Daniel Mario Vega dv5a at
Tue Feb 26 05:32:15 CST 2008


A few days ago I sent 2 patches for gdi32 to wine-patches that passed 
unnoticed. I would like if someone could give me some feedback on them.

Let me first give you some background about these patches. There is an 
application called "Compumap" that is a street map of some Argentine cities. 
It is rather popular here because some years ago it was distributed with a 

The program works quite well under Wine (although the installer still has some 
problems), but when you try to print a map it crashes.

A few weeks ago I had some free time and I decided to try to find out why it 
crashes. I run it through the Wine Debugger and also under a debugger in 
Windows XP.

The problem happened to be two API calls with incomplete/invalid parameters. 
Windows XP returned NULL or ignore the wrong data, while Wine crashes.

1) gdi32: Protect against short sized LOGPALETTE in CreatePalette.

This crash was caused by "CreatePalette(HDC, LOGPALETTE)" being called with a 
short allocated palette. Windows XP returned NULL in that case. I tried to 
reproduce that behavior by first checking the parameter with "IsBadReadPtr()" 

2) gdi32: StartDocA support for legacy apps with incomplete DOCINFOA 

This issue was a call to "StartDocA(HDC, DOCINFOA)" with structure DOCINFOA 
not completely initialized (there is garbage in the last 2 fields). I 
debugged this API and found that Windows XP ignored those fields when the 
data "seems to be invalid". I think that the last 2 fields were introduced in 
Win32 and some applications ported from Win16 "forget" to clear them. I 
simulated Windows XP behaviour by putting some safe checks on those fields.

With those 2 fixes, the application is able to print under Wine. Both patches 
are short and rather easy to review. I will appreciate if someone could give 
me some feedback on them.

Thanks ...

Daniel Mario Vega

More information about the wine-devel mailing list