[0.4.8] cherry-pick [SHELL32] Fix a directory handle leak when browsing folders
authorPierre Schweitzer <pierre@reactos.org>
Tue, 6 Mar 2018 19:22:50 +0000 (20:22 +0100)
committerJoachim Henze <Joachim.Henze@reactos.org>
Tue, 6 Mar 2018 19:51:08 +0000 (20:51 +0100)
commitf4b2e5310b173b8dd71b4ab4405a4f566bd1c92c
tree57c2cd06a67105f2bf4083b2cabac997ef9bcb42
parent5231a7f99697d1c612fd024861ca9ed23653bf95
[0.4.8] cherry-pick [SHELL32] Fix a directory handle leak when browsing folders

A bit of history: in r71528, I tried to fix our explorer often
crashing while browsing directories. It was linked to the fact
that a notification result may arrive while the notification
structure had already been deleted.

The fix for this was actually broken and was leading to a double
leak: the notification structure was leaked. But also the handle
to the directory that had been browsed!
This means that the directory couldn't be modified anymore as
a leaked handle to it was still open.

Actually, when notifications are cancel, the kernel properly
calls the notification routine, but with a specific error code.
So the correct fix is to stop handling that notification when
we receive this error code. This is the correct fix with no leaks.

This commit is a complete r71528 revert with the appropriate fix.

CORE-10941
CORE-12843

(cherry picked from commit da8a41b97bef45f28a1c85c17b99b1bfe22b4008)
cherry-picked by Joachim Henze with many thanks to Pierre.
dll/win32/shell32/wine/changenotify.c