[RPCRT4]
authorJérôme Gardou <jerome.gardou@reactos.org>
Mon, 16 Jun 2014 16:31:06 +0000 (16:31 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Mon, 16 Jun 2014 16:31:06 +0000 (16:31 +0000)
 - Free parameters allocated by application before anything else.
See CORE-8200 #comment committed in r63605, waiting for wine to accept it before closing.

svn path=/trunk/; revision=63605

reactos/dll/win32/rpcrt4/ndr_stubless.c

index e43ddde..72a8537 100644 (file)
@@ -1079,6 +1079,19 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
     unsigned int i;
     LONG_PTR *retval_ptr = NULL;
 
+    if (phase == STUBLESS_FREE)
+    {
+        /* Process the params allocated by the application first */
+        for (i = 0; i < number_of_params; i++)
+        {
+            unsigned char *pArg = pStubMsg->StackTop + params[i].stack_offset;
+            if (params[i].attr.MustFree)
+            {
+                call_freer(pStubMsg, pArg, &params[i]);
+            }
+        }
+    }
+
     for (i = 0; i < number_of_params; i++)
     {
         unsigned char *pArg = pStubMsg->StackTop + params[i].stack_offset;
@@ -1096,11 +1109,7 @@ static LONG_PTR *stub_do_args(MIDL_STUB_MESSAGE *pStubMsg,
                 call_marshaller(pStubMsg, pArg, &params[i]);
             break;
         case STUBLESS_FREE:
-            if (params[i].attr.MustFree)
-            {
-                call_freer(pStubMsg, pArg, &params[i]);
-            }
-            else if (params[i].attr.ServerAllocSize)
+            if (params[i].attr.ServerAllocSize)
             {
                 HeapFree(GetProcessHeap(), 0, *(void **)pArg);
             }