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

This commit is contained in:
Mike McCormack 2006-01-09 17:16:32 +01:00 committed by Alexandre Julliard
parent c83a5930b1
commit 3066397bab
2 changed files with 12 additions and 2 deletions

View File

@ -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
{

View File

@ -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);
}