Shell32: Check null handles before freeing

Nikolay Sivov bunglehead at
Wed Nov 25 02:11:30 CST 2015

On 25.11.2015 10:02, Olivier F. R. Dierick wrote:
> Fix one of the error leak source that prevents the installer to succeed
> (bug 36838).
> The original code did not check if the handles were null before freeing
> them. For some reason they happen to be null and last error is set to
> ERROR_INVALID_HANDLE. The game installer chokes at some point when the
> last error is anything but zero and fails to complete the installation.
> Checking if the handles are non-null before freeing them avoids this.
> According to MSDN, it is not an error to have null values for those
> handles.
> Signed-off-by: Olivier F. R. Dierick <o.dierick at>
> ---
>   dlls/shell32/changenotify.c |    6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)

We most likely have many more places that do same thing, it will need 
tests for SHFree() and CoTaskMemFree(). If it turns out error is not 
changed on NULLs, it's easier to return early from SHFree or 
CoTaskMemFree than fix all places where those are used.

More information about the wine-devel mailing list