From: Huw Davies Subject: rpcrt4/tests: Avoid a double-free. Message-Id: <1429520249-10211-1-git-send-email-huw@codeweavers.com> Date: Mon, 20 Apr 2015 09:57:29 +0100 Commit 4cf70b1418260fda95d69bcb50374a64f1ce895b was causing the tests to crash. The reason is due to a Wine bug in NdrPointerUnmarshall(). Windows returns the same pointer (which is later released in a call to NdrPointerFree()), while Wine makes a copy which Valgrind correctly spots is leaked. --- dlls/rpcrt4/tests/ndr_marshall.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c index 917c9e5..411ba8b 100644 --- a/dlls/rpcrt4/tests/ndr_marshall.c +++ b/dlls/rpcrt4/tests/ndr_marshall.c @@ -1560,6 +1560,11 @@ todo_wine { ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called); } + /* Prevent a memory leak when running with Wine. + Remove once the todo_wine block above is fixed. */ + if (mem != mem_orig) + HeapFree(GetProcessHeap(), 0, mem_orig); + my_free_called = 0; StubMsg.Buffer = StubMsg.BufferStart; NdrPointerFree( &StubMsg, mem, fmtstr_conf_str ); @@ -1590,7 +1595,6 @@ todo_wine { "mem not pointing at buffer %p/%p\n", mem, StubMsg.BufferStart + 12 ); ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called); } - HeapFree(GetProcessHeap(), 0, mem_orig); my_alloc_called = 0; mem = mem_orig = HeapAlloc(GetProcessHeap(), 0, sizeof(memsrc)); -- 1.8.0