Fixes a crash when QI'ing on async xpcom event proxy. r=rpotts, sr=jband, a=blizzard
git-svn-id: svn://10.0.0.236/trunk@102176 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
438c6aaae7
commit
161d8dd0c6
@ -403,20 +403,42 @@ nsProxyObject::Post( PRUint32 methodIndex, nsXPTMethodInfo *methodInfo, nsXPTCMi
|
||||
if (methodInfo->IsNotXPCOM())
|
||||
return NS_ERROR_PROXY_INVALID_IN_PARAMETER;
|
||||
|
||||
|
||||
PLEvent *event = PR_NEW(PLEvent);
|
||||
|
||||
if (event == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsXPTCVariant *fullParam;
|
||||
uint8 paramCount;
|
||||
rv = convertMiniVariantToVariant(methodInfo, params, &fullParam, ¶mCount);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
PR_DELETE(event);
|
||||
return rv;
|
||||
|
||||
if (!fullParam)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool callDirectly;
|
||||
|
||||
// see if we should call into the method directly. Either it is a QI function call
|
||||
// (methodIndex == 0), or it is a sync proxy and this code is running on the same thread
|
||||
// as the destination event queue.
|
||||
if ( (methodIndex == 0) ||
|
||||
(mProxyType & PROXY_SYNC &&
|
||||
NS_SUCCEEDED(mDestQueue->IsQueueOnCurrentThread(&callDirectly)) &&
|
||||
callDirectly))
|
||||
{
|
||||
|
||||
// invoke the magic of xptc...
|
||||
nsresult rv = XPTC_InvokeByIndex( mRealObject,
|
||||
methodIndex,
|
||||
paramCount,
|
||||
fullParam);
|
||||
|
||||
free(fullParam); // allocated with malloc
|
||||
return rv;
|
||||
}
|
||||
|
||||
PLEvent *event = PR_NEW(PLEvent);
|
||||
|
||||
if (event == nsnull) {
|
||||
free(fullParam);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsProxyObjectCallInfo *proxyInfo = new nsProxyObjectCallInfo(this,
|
||||
@ -427,12 +449,7 @@ nsProxyObject::Post( PRUint32 methodIndex, nsXPTMethodInfo *methodInfo, nsXPTCMi
|
||||
event); // will be deleted by ~()
|
||||
|
||||
if (proxyInfo == nsnull)
|
||||
{
|
||||
PR_DELETE(event);
|
||||
if (fullParam)
|
||||
free(fullParam); // allocated with malloc
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PL_InitEvent(event,
|
||||
proxyInfo,
|
||||
@ -441,24 +458,11 @@ nsProxyObject::Post( PRUint32 methodIndex, nsXPTMethodInfo *methodInfo, nsXPTCMi
|
||||
|
||||
if (mProxyType & PROXY_SYNC)
|
||||
{
|
||||
PRBool callDirectly;
|
||||
mDestQueue->IsQueueOnCurrentThread(&callDirectly);
|
||||
|
||||
if (callDirectly)
|
||||
{
|
||||
EventHandler(event);
|
||||
PL_DestroyEvent(event);
|
||||
// there is no need to call the DestroyHandler() because
|
||||
// there is no need to wake up the nested event loop.
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = PostAndWait(proxyInfo);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
rv = PostAndWait(proxyInfo);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = proxyInfo->GetResult();
|
||||
delete proxyInfo;
|
||||
return rv;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user