Commit c867f332 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Free fd entries with incorrect HANDLE value.

parent 190c67c7
...@@ -797,18 +797,15 @@ int CDECL MSVCRT__close(int fd) ...@@ -797,18 +797,15 @@ int CDECL MSVCRT__close(int fd)
LOCK_FILES(); LOCK_FILES();
hand = msvcrt_fdtoh(fd); hand = msvcrt_fdtoh(fd);
TRACE(":fd (%d) handle (%p)\n",fd,hand); TRACE(":fd (%d) handle (%p)\n",fd,hand);
if (hand == INVALID_HANDLE_VALUE) if (!msvcrt_is_valid_fd(fd)) {
ret = -1;
else if (!CloseHandle(hand))
{
WARN(":failed-last error (%d)\n",GetLastError());
msvcrt_set_errno(GetLastError());
ret = -1; ret = -1;
} } else {
else
{
msvcrt_free_fd(fd); 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(); UNLOCK_FILES();
TRACE(":ok\n"); TRACE(":ok\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment