kernel32: Fix GlobalReAlloc for size = 0.

GlobalReAlloc should return NULL if the requested size is 0, the block
is moveable and it is locked, but otherwise it should return the
original memory block.
This commit is contained in:
Robert Shearman 2006-01-12 11:55:25 +01:00 committed by Alexandre Julliard
parent 49eecf5128
commit 9cc41d278f
2 changed files with 13 additions and 13 deletions

View File

@ -656,12 +656,18 @@ HGLOBAL WINAPI GlobalReAlloc(
}
}
else
{
if (pintern->LockCount == 0)
{
if(pintern->Pointer)
{
HeapFree(GetProcessHeap(), 0, (char *) pintern->Pointer-HGLOBAL_STORAGE);
pintern->Pointer = NULL;
}
hnew = hmem;
}
else
WARN("not freeing memory associated with locked handle\n");
}
}
}

View File

@ -63,11 +63,8 @@ START_TEST(heap)
size = GlobalSize(gbl);
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
todo_wine
{
gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE);
ok(gbl != NULL, "GlobalReAlloc should not fail on size 0\n");
}
size = GlobalSize(gbl);
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
@ -87,11 +84,8 @@ START_TEST(heap)
size = LocalSize(gbl);
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
todo_wine
{
gbl = LocalReAlloc(gbl, 0, LMEM_MOVEABLE);
ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n");
}
size = LocalSize(gbl);
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);