From 88bbbed176807010312c96ee8e5d2ead06a2fc9d Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Wed, 9 Aug 2006 18:17:00 +0100 Subject: [PATCH] rpcrt4: Change call_memory_sizer to preserve the buffer contents and initialise the memory size field to zero before calling the memory sizer function. --- dlls/rpcrt4/ndr_stubless.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dlls/rpcrt4/ndr_stubless.c b/dlls/rpcrt4/ndr_stubless.c index 9206c388cf6..3b1c071784a 100644 --- a/dlls/rpcrt4/ndr_stubless.c +++ b/dlls/rpcrt4/ndr_stubless.c @@ -94,7 +94,18 @@ static inline void call_freer(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemor static inline unsigned long call_memory_sizer(PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat) { NDR_MEMORYSIZE m = NdrMemorySizer[pFormat[0] & NDR_TABLE_MASK]; - if (m) return m(pStubMsg, pFormat); + if (m) + { + unsigned char *saved_buffer = pStubMsg->Buffer; + unsigned long ret; + int saved_ignore_embedded_pointers = pStubMsg->IgnoreEmbeddedPointers; + pStubMsg->MemorySize = 0; + pStubMsg->IgnoreEmbeddedPointers = 1; + ret = m(pStubMsg, pFormat); + pStubMsg->IgnoreEmbeddedPointers = saved_ignore_embedded_pointers; + pStubMsg->Buffer = saved_buffer; + return ret; + } else { FIXME("format type 0x%x not implemented\n", pFormat[0]);