The current architecture cannot handle pipes changing address, so use

a static array. Fixes memory corruption that sometimes occurs when
using multiple pipes.
This commit is contained in:
Robert Shearman 2005-01-07 15:33:26 +00:00 committed by Alexandre Julliard
parent 67d3afb0d1
commit 090003360f

View File

@ -110,7 +110,9 @@ typedef struct _wine_pipe {
APARTMENT *apt; /* apartment of the marshalling thread for the stub dispatch case */ APARTMENT *apt; /* apartment of the marshalling thread for the stub dispatch case */
} wine_pipe; } wine_pipe;
static wine_pipe *pipes = NULL; #define MAX_WINE_PIPES 256
static wine_pipe pipes[MAX_WINE_PIPES];
static int nrofpipes = 0; static int nrofpipes = 0;
typedef struct _PipeBuf { typedef struct _PipeBuf {
@ -118,7 +120,6 @@ typedef struct _PipeBuf {
DWORD ref; DWORD ref;
wine_marshal_id mid; wine_marshal_id mid;
wine_pipe *pipe;
} PipeBuf; } PipeBuf;
static HRESULT WINAPI static HRESULT WINAPI
@ -181,17 +182,15 @@ static HRESULT
PIPE_RegisterPipe(wine_marshal_id *mid, HANDLE hPipe, BOOL startreader) { PIPE_RegisterPipe(wine_marshal_id *mid, HANDLE hPipe, BOOL startreader) {
int i; int i;
char pipefn[100]; char pipefn[100];
wine_pipe *new_pipes;
for (i=0;i<nrofpipes;i++) for (i=0;i<nrofpipes;i++)
if (pipes[i].mid.oxid==mid->oxid) if (pipes[i].mid.oxid==mid->oxid)
return S_OK; return S_OK;
if (pipes) if (nrofpipes + 1 >= MAX_WINE_PIPES)
new_pipes=(wine_pipe*)HeapReAlloc(GetProcessHeap(),0,pipes,sizeof(pipes[0])*(nrofpipes+1)); {
else FIXME("Out of pipes, please increase MAX_WINE_PIPES\n");
new_pipes=(wine_pipe*)HeapAlloc(GetProcessHeap(),0,sizeof(pipes[0])); return E_OUTOFMEMORY;
if (!new_pipes) return E_OUTOFMEMORY; }
pipes = new_pipes;
sprintf(pipefn,OLESTUBMGR"_%08lx%08lx",(DWORD)(mid->oxid >> 32),(DWORD)mid->oxid); sprintf(pipefn,OLESTUBMGR"_%08lx%08lx",(DWORD)(mid->oxid >> 32),(DWORD)mid->oxid);
memcpy(&(pipes[nrofpipes].mid),mid,sizeof(*mid)); memcpy(&(pipes[nrofpipes].mid),mid,sizeof(*mid));
pipes[nrofpipes].hPipe = hPipe; pipes[nrofpipes].hPipe = hPipe;