Zebediah Figura : rpcrt4: Unmarshal into a stack pointer on the server side if possible.

Alexandre Julliard julliard at winehq.org
Wed Oct 17 18:15:43 CDT 2018


Module: wine
Branch: master
Commit: 5fae77e4db87ae9db03dd95c43a8978a374c59b4
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=5fae77e4db87ae9db03dd95c43a8978a374c59b4

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Tue Oct 16 18:49:54 2018 -0500

rpcrt4: Unmarshal into a stack pointer on the server side if possible.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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;




More information about the wine-cvs mailing list