Commit 9cc41d27 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

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.
parent 49eecf51
...@@ -657,11 +657,17 @@ HGLOBAL WINAPI GlobalReAlloc( ...@@ -657,11 +657,17 @@ HGLOBAL WINAPI GlobalReAlloc(
} }
else else
{ {
if (pintern->LockCount == 0)
{
if(pintern->Pointer) if(pintern->Pointer)
{ {
HeapFree(GetProcessHeap(), 0, (char *) pintern->Pointer-HGLOBAL_STORAGE); HeapFree(GetProcessHeap(), 0, (char *) pintern->Pointer-HGLOBAL_STORAGE);
pintern->Pointer=NULL; pintern->Pointer = NULL;
} }
hnew = hmem;
}
else
WARN("not freeing memory associated with locked handle\n");
} }
} }
} }
......
...@@ -63,11 +63,8 @@ START_TEST(heap) ...@@ -63,11 +63,8 @@ START_TEST(heap)
size = GlobalSize(gbl); size = GlobalSize(gbl);
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size); ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
todo_wine
{
gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE); gbl = GlobalReAlloc(gbl, 0, GMEM_MOVEABLE);
ok(gbl != NULL, "GlobalReAlloc should not fail on size 0\n"); ok(gbl != NULL, "GlobalReAlloc should not fail on size 0\n");
}
size = GlobalSize(gbl); size = GlobalSize(gbl);
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size); ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
...@@ -87,11 +84,8 @@ START_TEST(heap) ...@@ -87,11 +84,8 @@ START_TEST(heap)
size = LocalSize(gbl); size = LocalSize(gbl);
ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size); ok(size >= 10 && size <= 16, "Memory not resized to size 10, instead size=%ld\n", size);
todo_wine
{
gbl = LocalReAlloc(gbl, 0, LMEM_MOVEABLE); gbl = LocalReAlloc(gbl, 0, LMEM_MOVEABLE);
ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n"); ok(gbl != NULL, "LocalReAlloc should not fail on size 0\n");
}
size = LocalSize(gbl); size = LocalSize(gbl);
ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size); ok(size == 0, "Memory not resized to size 0, instead size=%ld\n", size);
......
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