Despite Michael Müller's claim that all patches in wine-staging actually fix
something [1], I've come across several patch sets over the years that seem to
be related to some contemporaneous work but don't actually fix any application
themselves (e.g. wine-staging commits 5d8901ac21, ba9a7a6a74, probably most of
e353590528; I think there are plenty of other examples as well.)
This patch appears to fall into this category. The upstream commit it was
written in response to was bc68b30d20.
The application in question is buggy. It uses OpenFile(), but compares the
return value to 0 instead of -1. The open in question is the first in the
program's run. The problem occurs if the DOS handles are unassigned, in which
case the valid handle 0 will be returned, and the program will interpret it as
failure, hit some broken code path, and crash.
bc68b30d20 fixes this by ensuring that the DOS standard handles are always
valid, and therefore OpenFile() will always return at least 5. This seems to
match what happens on Windows. I can reproduce this fix; I didn't go to the
trouble of building its parent, but reverting that patch in current Wine does
make the program crash the exact same way (comparing to the +relay log helpfully
provided in the bug report).
Sebastian probably saw this commit, thought that "well, there's multiple ways
for a handle to be invalid", wrote this patch catching the additional ones, and
for some reason never submitted it upstream.
Thing is, these handles come from the server, and they're guaranteed to be
either valid or zero. As evidence cf. the duplicate_handle() calls in the
new_process request handler, which were present even at the time. Hence this
patch isn't doing anything, so remove it.
[1] https://www.winehq.org/mailman3/hyperkitty/list/wine-devel@winehq.org/message/YGKVQN2N537MXAVSMLHX5IV4XCEWKBVY/
The tests are left alone since they aren't particularly important and will need to be rewritten anyway.
They should probably be somewhere other than input.c, since they don't actually relate to input.
After upstream commit 62a979347a4dc1bd68f79b86397de85c016ec588
any TRACE() present on the way of virtual_init() will cause
a crash with WINEDEBUG present regardless of actual debug channels.
Avoid TRACE in virtual_init().