Modify

#3619 closed Bug (Fixed)

Return value of _WinAPI_LocalFree() is not consistent with what the documentation says

Reported by: tukangusil7@… Owned by: J-Paul Mesnage
Milestone: 3.3.15.1 Component: Standard UDFs
Version: 3.3.14.5 Severity: None
Keywords: LocalFree _WinAPI_LocalFree Cc:

Description

Return Value according to the documentation
Success: True
Failure: False, call _WinAPI_GetLastError() to ...

In WinAPIMem.au3

Func _WinAPI_LocalFree($hMemory)
  Local $aResult = DllCall("kernel32.dll", "handle", "LocalFree", "handle", $hMemory)
  If @error Then Return SetError(@error, @extended, False)

  Return $aResult[0]
EndFunc   ;==>_WinAPI_LocalFree

If the error is caused by the DllCall(), the documentation is correct.

However, the return value of LocalFree() itself according to MSDN is:

  • If the function succeeds, the return value is NULL.
  • If the function fails, the return value is equal to a handle to the local memory object. To get extended error information, call GetLastError().

Thus, if LocalFree() returns 0 (which means successful), _WinAPI_LocalFree() returns False (which means failed).

Attachments (0)

Change History (2)

comment:1 by J-Paul Mesnage, on Mar 23, 2018 at 8:36:58 AM

You right, doc will be fixed next release

comment:2 by J-Paul Mesnage, on Mar 23, 2018 at 9:09:31 AM

Milestone: 3.3.15.1
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [12082] in version: 3.3.15.1

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.