From 9ab603b0333dceb2373e78afceb0bf3d4b4bb502 Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Sat, 1 Jun 2013 22:01:41 +0900 Subject: [PATCH] kernel32: Don't move fixed memory area in GlobalReAlloc. --- dlls/kernel32/heap.c | 2 ++ dlls/kernel32/tests/heap.c | 28 ++++++---------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/dlls/kernel32/heap.c b/dlls/kernel32/heap.c index e0b86e57358..51bd235806b 100644 --- a/dlls/kernel32/heap.c +++ b/dlls/kernel32/heap.c @@ -646,6 +646,8 @@ HGLOBAL WINAPI GlobalReAlloc( if(ISPOINTER(hmem)) { /* reallocate fixed memory */ + if (!(flags & GMEM_MOVEABLE)) + heap_flags |= HEAP_REALLOC_IN_PLACE_ONLY; hnew=HeapReAlloc(GetProcessHeap(), heap_flags, hmem, size); } else diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c index 866abb80f43..e36336cdd14 100644 --- a/dlls/kernel32/tests/heap.c +++ b/dlls/kernel32/tests/heap.c @@ -251,17 +251,9 @@ static void test_heap(void) gbl = GlobalAlloc(GMEM_FIXED, init_size); SetLastError(MAGIC_DEAD); hsecond = GlobalReAlloc(gbl, size + init_size, 0); - if (hsecond != gbl) { - todo_wine - ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY), - "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size); - GlobalFree(hsecond); - } - else { - ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY), - "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size); - GlobalFree(gbl); - } + ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY), + "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size); + GlobalFree(gbl); } /* GMEM_FIXED block can be relocated with GMEM_MOVEABLE */ @@ -418,17 +410,9 @@ static void test_heap(void) gbl = LocalAlloc(LMEM_FIXED, init_size); SetLastError(MAGIC_DEAD); hsecond = LocalReAlloc(gbl, size + init_size, 0); - if (hsecond != gbl) { - todo_wine - ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY), - "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size); - LocalFree(hsecond); - } - else { - ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY), - "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size); - LocalFree(gbl); - } + ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY), + "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size); + LocalFree(gbl); } /* LMEM_FIXED memory can be relocated with LMEM_MOVEABLE */ -- 2.11.4.GIT