rpcrt4: Fix NdrConformantStringUnmarshall to use buffer memory if possible.
This commit is contained in:
parent
b300189c43
commit
259879d1f5
|
@ -826,6 +826,20 @@ unsigned char *WINAPI NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg
|
|||
ReadConformance(pStubMsg, NULL);
|
||||
ReadVariance(pStubMsg, NULL, pStubMsg->MaxCount);
|
||||
|
||||
if (pFormat[1] != RPC_FC_STRING_SIZED && (pStubMsg->MaxCount != pStubMsg->ActualCount))
|
||||
{
|
||||
ERR("buffer size %d must equal memory size %ld for non-sized conformant strings\n",
|
||||
pStubMsg->ActualCount, pStubMsg->MaxCount);
|
||||
RpcRaiseException(RPC_S_INVALID_BOUND);
|
||||
return NULL;
|
||||
}
|
||||
if (pStubMsg->Offset)
|
||||
{
|
||||
ERR("conformant strings can't have Offset (%d)\n", pStubMsg->Offset);
|
||||
RpcRaiseException(RPC_S_INVALID_BOUND);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (*pFormat == RPC_FC_C_CSTRING) esize = 1;
|
||||
else if (*pFormat == RPC_FC_C_WSTRING) esize = 2;
|
||||
else {
|
||||
|
@ -864,8 +878,17 @@ unsigned char *WINAPI NdrConformantStringUnmarshall( PMIDL_STUB_MESSAGE pStubMsg
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (fMustAlloc || !*ppMemory)
|
||||
if (fMustAlloc)
|
||||
*ppMemory = NdrAllocate(pStubMsg, memsize);
|
||||
else
|
||||
{
|
||||
if (!pStubMsg->IsClient && !*ppMemory && (pStubMsg->MaxCount == pStubMsg->ActualCount))
|
||||
/* if the data in the RPC buffer is big enough, we just point straight
|
||||
* into it */
|
||||
*ppMemory = pStubMsg->Buffer;
|
||||
else if (!*ppMemory)
|
||||
*ppMemory = NdrAllocate(pStubMsg, memsize);
|
||||
}
|
||||
|
||||
safe_copy_from_buffer(pStubMsg, *ppMemory, bufsize);
|
||||
|
||||
|
|
|
@ -1207,10 +1207,9 @@ todo_wine {
|
|||
mem = NULL;
|
||||
StubMsg.Buffer = StubMsg.BufferStart;
|
||||
NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 0);
|
||||
todo_wine {
|
||||
ok(mem == StubMsg.BufferStart + 12, "mem not pointing at buffer\n");
|
||||
ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
|
||||
}
|
||||
|
||||
my_alloc_called = 0;
|
||||
mem = NULL;
|
||||
StubMsg.Buffer = StubMsg.BufferStart;
|
||||
|
@ -1224,10 +1223,8 @@ todo_wine {
|
|||
mem = mem_orig;
|
||||
StubMsg.Buffer = StubMsg.BufferStart;
|
||||
NdrPointerUnmarshall( &StubMsg, &mem, fmtstr_conf_str, 0);
|
||||
todo_wine {
|
||||
ok(mem == StubMsg.BufferStart + 12, "mem not pointing at buffer\n");
|
||||
ok(my_alloc_called == 0, "alloc called %d\n", my_alloc_called);
|
||||
}
|
||||
|
||||
my_alloc_called = 0;
|
||||
mem = mem_orig;
|
||||
|
|
Loading…
Reference in New Issue