Commit ded4b866 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

Revert "rpcrt4: Try to free every non-stack pointer in PointerFree now that…

Revert "rpcrt4: Try to free every non-stack pointer in PointerFree now that NdrFree does the sanity checking for us.". This reverts commit 6db648302ce43f625a073426a35a6f40b7869d8b. Tests show the assumptions in a commit that this commit depends on are not valid.
parent 9896938f
...@@ -1270,17 +1270,23 @@ static void PointerFree(PMIDL_STUB_MESSAGE pStubMsg, ...@@ -1270,17 +1270,23 @@ 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);
/* we should check if the memory comes from NdrAllocate,
* and deallocate only if so - checking if the pointer is between
* BufferStart and BufferEnd will not always work since the buffer
* may be reallocated when the server wants to marshal the reply */
if (Pointer >= (unsigned char *)pStubMsg->RpcMsg->Buffer ||
Pointer <= (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength)
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);
return; return;
} }
/* try to free everything else. NdrFree will do the job of sorting out
* whether we allocated it or whether the app did */
TRACE("freeing %p\n", Pointer); TRACE("freeing %p\n", Pointer);
NdrFree(pStubMsg, Pointer); NdrFree(pStubMsg, Pointer);
return; return;
notfree:
TRACE("not freeing %p\n", Pointer);
} }
/*********************************************************************** /***********************************************************************
......
...@@ -1193,7 +1193,9 @@ todo_wine { ...@@ -1193,7 +1193,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);
}
mem = my_alloc(10); mem = my_alloc(10);
my_free_called = 0; my_free_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