Rob Shearman : rpcrt4: Initialise the memory in test_simple_struct_marshal before passing it to NdrSimpleStructUnmarshall .

Alexandre Julliard julliard at winehq.org
Mon Dec 3 09:17:42 CST 2007


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

Author: Rob Shearman <rob at codeweavers.com>
Date:   Fri Nov 30 22:03:39 2007 +0000

rpcrt4: Initialise the memory in test_simple_struct_marshal before passing it to NdrSimpleStructUnmarshall.

Otherwise, the unmarshalling code will read from unintialised memory
when trying to reuse the embedded pointers in the memory block.

Also fix a couple of memory leaks.

---

 dlls/rpcrt4/tests/ndr_marshall.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c
index 06b7b51..c935d08 100644
--- a/dlls/rpcrt4/tests/ndr_marshall.c
+++ b/dlls/rpcrt4/tests/ndr_marshall.c
@@ -514,7 +514,7 @@ todo_wine {
 
     StubMsg.Buffer = StubMsg.BufferStart;
     StubMsg.MemorySize = 0;
-    mem_orig = mem = HeapAlloc(GetProcessHeap(), 0, srcsize);
+    mem_orig = mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, srcsize);
     ptr = NdrSimpleStructUnmarshall( &StubMsg, &mem, formattypes, 0 );
     ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
     ok(StubMsg.Buffer - StubMsg.BufferStart == wiredatalen, "%s: Buffer %p Start %p\n", msgpfx, StubMsg.Buffer, StubMsg.BufferStart);
@@ -600,6 +600,8 @@ todo_wine {
     my_alloc_called = 0;
     ok(StubMsg.MemorySize == 0, "memorysize touched in unmarshal\n");
 
+    HeapFree(GetProcessHeap(), 0, mem_orig);
+    HeapFree(GetProcessHeap(), 0, StubMsg.BufferStart);
 }
 
 typedef struct




More information about the wine-cvs mailing list