kernel: Trying to lock an empty global memory block gives an ERROR_DISCARDED.
This commit is contained in:
parent
c83a5930b1
commit
3066397bab
|
@ -413,9 +413,11 @@ LPVOID WINAPI GlobalLock(
|
||||||
pintern = HANDLE_TO_INTERN(hmem);
|
pintern = HANDLE_TO_INTERN(hmem);
|
||||||
if (pintern->Magic == MAGIC_GLOBAL_USED)
|
if (pintern->Magic == MAGIC_GLOBAL_USED)
|
||||||
{
|
{
|
||||||
if (pintern->LockCount < GLOBAL_LOCK_MAX)
|
|
||||||
pintern->LockCount++;
|
|
||||||
palloc = pintern->Pointer;
|
palloc = pintern->Pointer;
|
||||||
|
if (!pintern->Pointer)
|
||||||
|
SetLastError(ERROR_DISCARDED);
|
||||||
|
else if (pintern->LockCount < GLOBAL_LOCK_MAX)
|
||||||
|
pintern->LockCount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,4 +102,12 @@ START_TEST(heap)
|
||||||
gbl = LocalReAlloc(0, 10, LMEM_MOVEABLE);
|
gbl = LocalReAlloc(0, 10, LMEM_MOVEABLE);
|
||||||
ok(gbl == NULL, "local realloc allocated memory\n");
|
ok(gbl == NULL, "local realloc allocated memory\n");
|
||||||
|
|
||||||
|
/* trying to lock empty memory should give an error */
|
||||||
|
gbl = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,0);
|
||||||
|
ok(gbl != NULL, "returned NULL\n");
|
||||||
|
SetLastError(0xdeadbeef);
|
||||||
|
mem = GlobalLock(gbl);
|
||||||
|
ok( GetLastError() == ERROR_DISCARDED, "should return an error\n");
|
||||||
|
ok( mem == NULL, "should return NULL\n");
|
||||||
|
GlobalFree(gbl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue