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:
parent
49eecf5128
commit
9cc41d278f
|
@ -657,11 +657,17 @@ HGLOBAL WINAPI GlobalReAlloc(
|
|||
}
|
||||
else
|
||||
{
|
||||
if(pintern->Pointer)
|
||||
if (pintern->LockCount == 0)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, (char *) pintern->Pointer-HGLOBAL_STORAGE);
|
||||
pintern->Pointer=NULL;
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
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");
|
||||
}
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue