Francois Gouget <[EMAIL PROTECTED]> writes: > On Thu, 8 Mar 2007, Alexandre Julliard wrote: > [...] >> Note that a valid file handle will never be NULL, so while these >> checks are wrong in theory, in practice it makes no difference. > > Right. But the invalid check means that in some cases we will call > CloseHandle(INVALID_HANDLE_VALUE) which the MSDN has this to say about: > >> If the application is running under a debugger, the function will >> throw an exception if it receives either a handle value that is not >> valid or a pseudo-handle value. This can happen if you close a handle >> twice, or if you call CloseHandle on a handle returned by the >> FindFirstFile function. > > I did not check but I guess Wine does not do that... so far. It's still > best avoided.
Sure, it's best to avoid closing an invalid handle. We don't throw an exception but we do set last error, and this could conceivably break something. But the NULL check is not going to cause us to forget to close a valid handle, which would be a much worse problem. -- Alexandre Julliard [EMAIL PROTECTED]