Protect some DIB functions from bad inputs.

Mike Hearn mike at
Wed Apr 12 05:52:16 CDT 2006

On Wed, 12 Apr 2006 14:44:18 +0400, Vitaly Lipatov wrote:
> I know many MS's dlls use IsBadReadPtr for check pointers.
> IsBadReadPtr is malfunction conceptually or it is not realized correctly yet?

The problem is you can't use it in thread safe code, because the pointer
may be correct when you test it and then go bad immediately afterwards. So
using it in Wine code is almost always a race condition.

There is another problem with it. It can blow away the stack guard page so
causing the stack to not grow correctly.

The thread-safe way to do this sort of thing is always to trap the error
if there is one. You can't know until you try whether it'll work or not,
in other words.

IsBad*Ptr has historically been used throughout Win32 to verify arguments,
but this was never a good idea and in Vista it has been "banned", which I
guess means Microsoft have gone through and removed the tests. Or at least
are not using them anymore for new APIs.

thanks -mike

More information about the wine-devel mailing list