ChangeSet ID: 21450 CVSROOT: /opt/cvs-commit Module name: wine Changes by: julliard@winehq.org 2005/11/28 05:00:06
Modified files: dlls/rpcrt4 : ndr_marshall.c
Log message: Robert Shearman rob@codeweavers.com We should always allocate in NdrConformantStringUnmarshal if the memory pointer is NULL.
Patch: http://cvs.winehq.org/patch.py?id=21450
Old revision New revision Changes Path 1.30 1.31 +4 -15 wine/dlls/rpcrt4/ndr_marshall.c
Index: wine/dlls/rpcrt4/ndr_marshall.c diff -u -p wine/dlls/rpcrt4/ndr_marshall.c:1.30 wine/dlls/rpcrt4/ndr_marshall.c:1.31 --- wine/dlls/rpcrt4/ndr_marshall.c:1.30 28 Nov 2005 11: 0: 6 -0000 +++ wine/dlls/rpcrt4/ndr_marshall.c 28 Nov 2005 11: 0: 6 -0000 @@ -526,7 +526,6 @@ unsigned char *WINAPI NdrConformantStrin unsigned char** ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc ) { unsigned long len, esize, ofs; - unsigned char *pMem;
TRACE("(pStubMsg == ^%p, *pMemory == ^%p, pFormat == ^%p, fMustAlloc == %u)\n", pStubMsg, *ppMemory, pFormat, fMustAlloc); @@ -551,28 +550,18 @@ unsigned char *WINAPI NdrConformantStrin FIXME("sized string format=%d\n", pFormat[1]); }
- if (fMustAlloc) { + if (fMustAlloc || !*ppMemory) *ppMemory = NdrAllocate(pStubMsg, len*esize + BUFFER_PARANOIA); - } else { - if (pStubMsg->ReuseBuffer && !*ppMemory) - /* for servers, we may just point straight into the RPC buffer, I think - * (I guess that's what MS does since MIDL code doesn't try to free) */ - *ppMemory = pStubMsg->Buffer - ofs*esize; - /* for clients, memory should be provided by caller */ - } - - pMem = *ppMemory + ofs*esize;
- if (pMem != pStubMsg->Buffer) - memcpy(pMem, pStubMsg->Buffer, len*esize); + memcpy(*ppMemory, pStubMsg->Buffer, len*esize);
pStubMsg->Buffer += len*esize;
if (*pFormat == RPC_FC_C_CSTRING) { - TRACE("string=%s\n", debugstr_a((char*)pMem)); + TRACE("string=%s\n", debugstr_a((char*)*ppMemory)); } else if (*pFormat == RPC_FC_C_WSTRING) { - TRACE("string=%s\n", debugstr_w((LPWSTR)pMem)); + TRACE("string=%s\n", debugstr_w((LPWSTR)*ppMemory)); }
return NULL; /* FIXME: is this always right? */