Commit 3066397b authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

kernel: Trying to lock an empty global memory block gives an ERROR_DISCARDED.

parent c83a5930
......@@ -413,9 +413,11 @@ LPVOID WINAPI GlobalLock(
pintern = HANDLE_TO_INTERN(hmem);
if (pintern->Magic == MAGIC_GLOBAL_USED)
{
if (pintern->LockCount < GLOBAL_LOCK_MAX)
pintern->LockCount++;
palloc = pintern->Pointer;
if (!pintern->Pointer)
SetLastError(ERROR_DISCARDED);
else if (pintern->LockCount < GLOBAL_LOCK_MAX)
pintern->LockCount++;
}
else
{
......
......@@ -102,4 +102,12 @@ START_TEST(heap)
gbl = LocalReAlloc(0, 10, LMEM_MOVEABLE);
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);
}
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