[Bug 51529] New: CloseHandle(INVALID_HANDLE_VALUE) returns FALSE, GetLastError is ERROR_INVALID_HANDLE

WineHQ Bugzilla wine-bugs at winehq.org
Tue Jul 27 06:55:43 CDT 2021


https://bugs.winehq.org/show_bug.cgi?id=51529

            Bug ID: 51529
           Summary: CloseHandle(INVALID_HANDLE_VALUE) returns FALSE,
                    GetLastError is ERROR_INVALID_HANDLE
           Product: Wine
           Version: 5.0
          Hardware: x86-64
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: kernel32
          Assignee: wine-bugs at winehq.org
          Reporter: sergey.bychkow at gmail.com
      Distribution: ---

Created attachment 70368
  --> https://bugs.winehq.org/attachment.cgi?id=70368
Test CloseHandle(INVALID_HANDLE_VALUE)

CloseHandle(INVALID_HANDLE_VALUE) returns FALSE, GetLastError is
ERROR_INVALID_HANDLE on Wine. I tried it with MacOSX and Linux.

But on Windows CloseHandle(INVALID_HANDLE_VALUE) returns TRUE. So many programs
could fail if they didn't expect FALSE here.

Test case (Pascal). Can be compiled with FPC or Delphi.

// file TestCloseHandle.lpr

program TestCloseHandle;

{$APPTYPE CONSOLE}

uses
  //Winapi.Windows;
  Windows;

var
  aHandle: THandle;
  aResult: HRESULT;
begin
  //aHandle := 0;
  aHandle := INVALID_HANDLE_VALUE;

  if CloseHandle(aHandle) then
    aResult := 0
  else
    aResult := GetLastError;

  Writeln('Result: ', aResult);
end.

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list