From c867f3324ec6fd1330c8b3228bc5db79f0b4833c Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 6 Oct 2011 20:13:38 +0200 Subject: [PATCH] msvcrt: Free fd entries with incorrect HANDLE value. --- dlls/msvcrt/file.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index ecbec34aa40..90e0d808822 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -797,18 +797,15 @@ int CDECL MSVCRT__close(int fd) LOCK_FILES(); hand = msvcrt_fdtoh(fd); TRACE(":fd (%d) handle (%p)\n",fd,hand); - if (hand == INVALID_HANDLE_VALUE) - ret = -1; - else if (!CloseHandle(hand)) - { - WARN(":failed-last error (%d)\n",GetLastError()); - msvcrt_set_errno(GetLastError()); + if (!msvcrt_is_valid_fd(fd)) { ret = -1; - } - else - { + } else { msvcrt_free_fd(fd); - ret = 0; + ret = CloseHandle(hand) ? 0 : -1; + if (ret) { + WARN(":failed-last error (%d)\n",GetLastError()); + msvcrt_set_errno(GetLastError()); + } } UNLOCK_FILES(); TRACE(":ok\n"); -- 2.11.4.GIT