mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 08:49:15 +00:00
kernel: Fix handling of invalid parameter in GlobalSize().
This commit is contained in:
parent
714b66e945
commit
839f00a967
2 changed files with 23 additions and 6 deletions
|
@ -751,13 +751,19 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hmem)
|
|||
*
|
||||
* Get the size of a global memory object.
|
||||
*
|
||||
* PARAMS
|
||||
* hmem [I] Handle of the global memory object
|
||||
*
|
||||
* RETURNS
|
||||
* Size in bytes of the global memory object
|
||||
* 0: Failure
|
||||
* Failure: 0
|
||||
* Success: Size in Bytes of the global memory object
|
||||
*
|
||||
* NOTES
|
||||
* When the handle is invalid, last error is set to ERROR_INVALID_HANDLE
|
||||
*
|
||||
*/
|
||||
SIZE_T WINAPI GlobalSize(
|
||||
HGLOBAL hmem /* [in] Handle of global memory object */
|
||||
) {
|
||||
SIZE_T WINAPI GlobalSize(HGLOBAL hmem)
|
||||
{
|
||||
DWORD retval;
|
||||
PGLOBAL32_INTERN pintern;
|
||||
|
||||
|
@ -785,7 +791,8 @@ SIZE_T WINAPI GlobalSize(
|
|||
}
|
||||
else
|
||||
{
|
||||
WARN("invalid handle\n");
|
||||
WARN("invalid handle %p (Magic: 0x%04x)\n", hmem, pintern->Magic);
|
||||
SetLastError(ERROR_INVALID_HANDLE);
|
||||
retval=0;
|
||||
}
|
||||
RtlUnlockHeap(GetProcessHeap());
|
||||
|
|
|
@ -92,6 +92,11 @@ START_TEST(heap)
|
|||
ok( (flags == GMEM_INVALID_HANDLE) && (GetLastError() == ERROR_INVALID_HANDLE),
|
||||
"returned 0x%04x with 0x%08lx (expected GMEM_INVALID_HANDLE with " \
|
||||
"ERROR_INVALID_HANDLE)\n", flags, GetLastError());
|
||||
SetLastError(MAGIC_DEAD);
|
||||
size = GlobalSize(gbl);
|
||||
ok( (size == 0) && (GetLastError() == ERROR_INVALID_HANDLE),
|
||||
"returned %ld with 0x%08lx (expected '0' with ERROR_INVALID_HANDLE)\n",
|
||||
size, GetLastError());
|
||||
|
||||
|
||||
/* Local*() functions */
|
||||
|
@ -128,6 +133,11 @@ START_TEST(heap)
|
|||
ok( (flags == LMEM_INVALID_HANDLE) && (GetLastError() == ERROR_INVALID_HANDLE),
|
||||
"returned 0x%04x with 0x%08lx (expected LMEM_INVALID_HANDLE with " \
|
||||
"ERROR_INVALID_HANDLE)\n", flags, GetLastError());
|
||||
SetLastError(MAGIC_DEAD);
|
||||
size = LocalSize(gbl);
|
||||
ok( (size == 0) && (GetLastError() == ERROR_INVALID_HANDLE),
|
||||
"returned %ld with 0x%08lx (expected '0' with ERROR_INVALID_HANDLE)\n",
|
||||
size, GetLastError());
|
||||
|
||||
|
||||
/* trying to lock empty memory should give an error */
|
||||
|
|
Loading…
Reference in a new issue