[PATCH 1/2] kernel32: test that HeapSize() works on GMEM_MOVEABLE global memory on Windows

Damjan Jovanovic damjan.jov at gmail.com
Sat Oct 26 01:36:10 CDT 2019


In #38924, Tapps 2, DirMaster, and even wxWidgets' sample code (and
thus probably many more wxWidgets applications out in the field), all
crash during drag-and-drop with custom formats, which they use to
implement within-application actions such as rearranging shapes and
moving text.

Luckily wxWidgets is our dog food and builds easily, so it could be
patched to investigate.

It turns out that wxWidgets expects HeapSize() to succeed on the
pointer to global memory returned by GlobalLock(). On Wine this fails,
causing wxWidgets to pass a NULL pointer to the application for the
drag-and-drop data. Application accesses NULL pointer -> crash.

This patch adds a test for this problem.

Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
---
 dlls/kernel32/tests/heap.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
-------------- next part --------------
diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c
index 38fae0eede..eff3242498 100644
--- a/dlls/kernel32/tests/heap.c
+++ b/dlls/kernel32/tests/heap.c
@@ -337,6 +337,16 @@ static void test_heap(void)
     ok( size == 1, "wrong size %lu\n", size );
     GlobalFree( gbl );
 
+    /* HeapSize on memory from a global pointer */
+    gbl = GlobalAlloc(GMEM_MOVEABLE, 100);
+    ok(gbl != NULL, "returned error %d\n", GetLastError());
+    mem = GlobalLock(gbl);
+    ok(mem != NULL, "returned error %d\n", GetLastError());
+    size = HeapSize(GetProcessHeap(), 0, mem);
+    todo_wine ok(size != (SIZE_T)-1 && size >= 100, "HeapSize returned %lu\n", size);
+    GlobalFree(gbl);
+
+
     /* ####################################### */
     /* Local*() functions */
     gbl = LocalAlloc(LMEM_MOVEABLE, 0);


More information about the wine-devel mailing list