Fix bug 554449. r=jst sr=peterv
This commit is contained in:
@@ -1324,6 +1324,31 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
|||||||
xpcc->SetException(nsnull);
|
xpcc->SetException(nsnull);
|
||||||
ccx.GetThreadData()->SetException(nsnull);
|
ccx.GetThreadData()->SetException(nsnull);
|
||||||
|
|
||||||
|
if(XPCPerThreadData::IsMainThread(ccx))
|
||||||
|
{
|
||||||
|
ssm = XPCWrapper::GetSecurityManager();
|
||||||
|
if(ssm)
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIPrincipal> objPrincipal;
|
||||||
|
ssm->GetObjectPrincipal(ccx, obj, getter_AddRefs(objPrincipal));
|
||||||
|
if(objPrincipal)
|
||||||
|
{
|
||||||
|
JSStackFrame* fp = nsnull;
|
||||||
|
nsresult rv =
|
||||||
|
ssm->PushContextPrincipal(ccx, JS_FrameIterator(ccx, &fp),
|
||||||
|
objPrincipal);
|
||||||
|
if(NS_FAILED(rv))
|
||||||
|
{
|
||||||
|
JS_ReportOutOfMemory(ccx);
|
||||||
|
retval = NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
goto pre_call_clean_up;
|
||||||
|
}
|
||||||
|
|
||||||
|
popPrincipal = JS_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We use js_AllocStack, js_Invoke, and js_FreeStack so that the gcthings
|
// We use js_AllocStack, js_Invoke, and js_FreeStack so that the gcthings
|
||||||
// we use as args will be rooted by the engine as we do conversions and
|
// we use as args will be rooted by the engine as we do conversions and
|
||||||
// prepare to do the function call. This adds a fair amount of complexity,
|
// prepare to do the function call. This adds a fair amount of complexity,
|
||||||
@@ -1660,31 +1685,6 @@ pre_call_clean_up:
|
|||||||
|
|
||||||
JS_ClearPendingException(cx);
|
JS_ClearPendingException(cx);
|
||||||
|
|
||||||
if(XPCPerThreadData::IsMainThread(ccx))
|
|
||||||
{
|
|
||||||
ssm = XPCWrapper::GetSecurityManager();
|
|
||||||
if(ssm)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIPrincipal> objPrincipal;
|
|
||||||
ssm->GetObjectPrincipal(ccx, obj, getter_AddRefs(objPrincipal));
|
|
||||||
if(objPrincipal)
|
|
||||||
{
|
|
||||||
JSStackFrame* fp = nsnull;
|
|
||||||
nsresult rv =
|
|
||||||
ssm->PushContextPrincipal(ccx, JS_FrameIterator(ccx, &fp),
|
|
||||||
objPrincipal);
|
|
||||||
if(NS_FAILED(rv))
|
|
||||||
{
|
|
||||||
JS_ReportOutOfMemory(ccx);
|
|
||||||
retval = NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
popPrincipal = JS_TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(XPT_MD_IS_GETTER(info->flags))
|
if(XPT_MD_IS_GETTER(info->flags))
|
||||||
success = JS_GetProperty(cx, obj, name, &result);
|
success = JS_GetProperty(cx, obj, name, &result);
|
||||||
else if(XPT_MD_IS_SETTER(info->flags))
|
else if(XPT_MD_IS_SETTER(info->flags))
|
||||||
@@ -1721,9 +1721,6 @@ pre_call_clean_up:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(popPrincipal)
|
|
||||||
ssm->PopContextPrincipal(ccx);
|
|
||||||
|
|
||||||
if(!success)
|
if(!success)
|
||||||
{
|
{
|
||||||
PRBool forceReport;
|
PRBool forceReport;
|
||||||
@@ -1939,6 +1936,9 @@ done:
|
|||||||
if(sp)
|
if(sp)
|
||||||
js_FreeStack(cx, mark);
|
js_FreeStack(cx, mark);
|
||||||
|
|
||||||
|
if(popPrincipal)
|
||||||
|
ssm->PopContextPrincipal(ccx);
|
||||||
|
|
||||||
#ifdef DEBUG_stats_jband
|
#ifdef DEBUG_stats_jband
|
||||||
endTime = PR_IntervalNow();
|
endTime = PR_IntervalNow();
|
||||||
printf("%s::%s %d ( c->js ) \n", GetInterfaceName(), info->GetName(), PR_IntervalToMilliseconds(endTime-startTime));
|
printf("%s::%s %d ( c->js ) \n", GetInterfaceName(), info->GetName(), PR_IntervalToMilliseconds(endTime-startTime));
|
||||||
|
|||||||
Reference in New Issue
Block a user