Commit 2ebee181 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

rpcrt4: Improve PointerFree to not free buffer memory.

parent 9de1b6a8
...@@ -1187,28 +1187,13 @@ static void PointerFree(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -1187,28 +1187,13 @@ static void PointerFree(PMIDL_STUB_MESSAGE pStubMsg,
m = NdrFreer[*desc & NDR_TABLE_MASK]; m = NdrFreer[*desc & NDR_TABLE_MASK];
if (m) m(pStubMsg, Pointer, desc); if (m) m(pStubMsg, Pointer, desc);
/* hmm... is this sensible? /* we should check if the memory comes from NdrAllocate,
* perhaps we should check if the memory comes from NdrAllocate,
* and deallocate only if so - checking if the pointer is between * and deallocate only if so - checking if the pointer is between
* BufferStart and BufferEnd is probably no good since the buffer * BufferStart and BufferEnd will not always work since the buffer
* may be reallocated when the server wants to marshal the reply */ * may be reallocated when the server wants to marshal the reply */
switch (*desc) { if (Pointer >= (unsigned char *)pStubMsg->RpcMsg->Buffer ||
case RPC_FC_BOGUS_STRUCT: Pointer <= (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
case RPC_FC_BOGUS_ARRAY:
case RPC_FC_USER_MARSHAL:
case RPC_FC_CARRAY:
case RPC_FC_CVARRAY:
break;
default:
FIXME("unhandled data type=%02x\n", *desc);
break;
case RPC_FC_C_CSTRING:
case RPC_FC_C_WSTRING:
if (pStubMsg->ReuseBuffer) goto notfree;
break;
case RPC_FC_IP:
goto notfree; goto notfree;
}
if (attr & RPC_FC_P_ONSTACK) { if (attr & RPC_FC_P_ONSTACK) {
TRACE("not freeing stack ptr %p\n", Pointer); TRACE("not freeing stack ptr %p\n", Pointer);
......
...@@ -1167,7 +1167,9 @@ todo_wine { ...@@ -1167,7 +1167,9 @@ todo_wine {
my_free_called = 0; my_free_called = 0;
StubMsg.Buffer = StubMsg.BufferStart; StubMsg.Buffer = StubMsg.BufferStart;
NdrPointerFree( &StubMsg, mem, fmtstr_conf_str ); NdrPointerFree( &StubMsg, mem, fmtstr_conf_str );
todo_wine {
ok(my_free_called == 1, "free called %d\n", my_free_called); ok(my_free_called == 1, "free called %d\n", my_free_called);
}
/* Server */ /* Server */
my_alloc_called = 0; my_alloc_called = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment