[PATCH 4/4] rpcrt4: Unmarshal into a stack pointer on the server side if possible.

Zebediah Figura z.figura12 at gmail.com
Tue Oct 16 18:49:54 CDT 2018


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/rpcrt4/ndr_marshall.c       | 5 ++++-
 dlls/rpcrt4/tests/ndr_marshall.c | 8 +++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c
index 58f0108..b48b300 100644
--- a/dlls/rpcrt4/ndr_marshall.c
+++ b/dlls/rpcrt4/ndr_marshall.c
@@ -944,7 +944,10 @@ static void PointerUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
        * setting the pointer to the buffer, if possible, or set fMustAlloc to
        * TRUE. */
       if (attr & FC_POINTER_DEREF) {
-        fMustAlloc = TRUE;
+        if (pSrcPointer && (attr & FC_ALLOCED_ON_STACK))
+          *pPointer = pSrcPointer;
+        else
+          fMustAlloc = TRUE;
       } else {
         *current_ptr = NULL;
       }
diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c
index e4231ae..2695d46 100644
--- a/dlls/rpcrt4/tests/ndr_marshall.c
+++ b/dlls/rpcrt4/tests/ndr_marshall.c
@@ -437,7 +437,6 @@ todo_wine
     ptr = NdrPointerUnmarshall( &StubMsg, &mem, formattypes, 0 );
     ok(ptr == NULL, "%s: ret %p\n", msgpfx, ptr);
     if ((formattypes[1] & FC_ALLOCED_ON_STACK) && (formattypes[1] & FC_POINTER_DEREF))
-todo_wine
         ok(mem == mem_orig, "%s: mem has changed %p %p\n", msgpfx, mem, mem_orig);
     else
         ok(mem != mem_orig, "%s: mem has not changed\n", msgpfx);
@@ -849,10 +848,9 @@ static void test_nontrivial_pointer_types(void)
     *(void **)mem = NULL;
     StubMsg.Buffer = StubMsg.BufferStart;
     NdrPointerUnmarshall( &StubMsg, &mem, &fmtstr_ref_unique_out[4], 0);
-    todo_wine {
-        ok(mem == mem_orig, "mem alloced\n");
-        ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
-    }
+    ok(mem == mem_orig, "mem alloced\n");
+todo_wine
+    ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
 
     my_alloc_called = 0;
     mem = mem_orig;
-- 
2.7.4




More information about the wine-devel mailing list