Huw Davies : rpcrt4/tests: Avoid a double-free.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Apr 20 08:24:42 CDT 2015


Module: wine
Branch: master
Commit: b24ce98af36431d1b7715db4090d903b82d095c3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b24ce98af36431d1b7715db4090d903b82d095c3

Author: Huw Davies <huw at codeweavers.com>
Date:   Mon Apr 20 09:57:29 2015 +0100

rpcrt4/tests: Avoid a double-free.

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));




More information about the wine-cvs mailing list